-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
37 lines (29 loc) · 946 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
const express = require('express');
const app = express();
// view engine setup
app.set('views', 'views');
app.set('view engine', 'pug');
const bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.text());
app.use(express.static('public'));
app.use('/', require('./routes/index'));
// catch 404 and forward to error handler
app.use(function(request, response, next) {
const error = new Error('Not Found');
error.status = 404;
next(error);
});
// error handler
app.use(function(error, request, response) {
// set locals, only providing error in development
response.locals.message = error.message;
response.locals.error = request.app.get('env') === 'development' ? error : {};
// render the error page
response.status(error.status || 500);
response.render('error');
});
app.listen(8000, function() {
console.log('You have a server on port 8000');
});
require('./components/websocket')();