-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
44 lines (35 loc) · 1.23 KB
/
index.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
41
42
43
44
// Tuneshuffle app server code
const express = require('express'),
color = require('cli-color'),
constants = require('./lib/constants'),
path = require('path'),
app = express(),
bodyParser = require('body-parser'),
woodlot = require('woodlot').middlewareLogger,
cookieParser = require('cookie-parser'),
opn = require('opn');
// Enable body/cookie parser middlewares
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cookieParser());
// Logger middleware
app.use(woodlot({
streams: ['./logs/tuneshuffle-server.log'],
stdout: true
}));
// Enable api module
require('./lib/api')(app);
// Setup public assets directory and view engine
app.use(express.static(path.join(__dirname, 'public')));
app.set('view engine', 'pug');
app.set('views', path.join(__dirname, 'views'));
// Setup app locals
app.locals.constants = constants;
// Setup default route
app.get('*', (req, res) => res.render('index'));
// Run app server on specified port
app.listen(constants.PORT, () => {
console.log(`${color.blue(constants.APP_TITLE)} is running on port : ${color.yellow(constants.PORT)}`);
// Open Tuneshuffle in browser window
//opn(`http://localhost:${constants.PORT}/welcome`);
});