-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
40 lines (32 loc) · 1.09 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const express = require('express')
, api = require('./api')
, path = require('path');
const bodyParser = require('body-parser');
const session = require('express-session');
const auth = require('./auth');
const app = express();
// Session Configuration
app.use(session({
secret: 'chefpieter',
resave: false,
saveUninitialized: true,
cookie : { maxAge: 6000}
}));
// ENV Configuration
//app.set('port', process.env.PORT || 5000);
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
// Serve static files from the React app
app.use(express.static(path.join(__dirname, 'client/build')));
// Get Spotify authtoken
api.getAuth();
// API routes
app.get('/api/spotify/playlists', api.playlists, api.getAuth);
app.get('/api/spotify/users/:user/playlists/:playlist/tracks', api.tracks);
app.post('/api/youtube', api.youtube);
app.get('*', function(req, res) {
res.sendFile(path.join(__dirname, 'client/build', 'index.html'));
});
app.listen(5000);
//https.createServer(sslconfig.credentials, app).listen(5000);
console.log(`Backend API listening on port 5000`);