forked from miguelgimenezgimenez/spotamovie-be
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (25 loc) · 783 Bytes
/
Copy pathindex.js
File metadata and controls
31 lines (25 loc) · 783 Bytes
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
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const morgan = require('morgan');
const spotifyApi = require('./lib/spotifyWebApi');
//local require\
const db=require('./db');
const router = require('./router.js');
const nconf = require('nconf');
//don't show the log when it is test
if(process.env.NODE_ENV !== 'test') {
//use morgan to log at command line
// app.use(morgan('combined')); //'combined' outputs the Apache style LOGs
}
app.use(bodyParser.json());
app.use(function(req, res, next){
req.spotifyApi = spotifyApi;
next();
});
app.use(router);
const port = nconf.get('PORT') || 3000;
app.listen(port, function () {
console.log('Listening on port ' + port);
});
module.exports = app; // for testing