-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (31 loc) · 992 Bytes
/
app.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
#!/usr/bin/env node
var express = require('express');
var path = require('path');
//var logger = require('morgan');
var bodyParser = require('body-parser');
var debug = require('debug')('westernapp:server');
var http = require('http');
var port = normalizePort(process.env.PORT || '3000');
var app = express();
app.set('port', port);
console.log('listen ', port);
var server = http.createServer(app);
server.listen(port);
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
//app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
app.use('/node_modules', express.static(path.join(__dirname, '/node_modules'))); //share node_modules with front-end;
app.use('/', require('./routes/index'));
function normalizePort(val) {
var port = parseInt(val, 10);
if (isNaN(port)) {
return val;
}
if (port >= 0) {
return port;
}
return false;
}