-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (25 loc) · 785 Bytes
/
Copy pathapp.js
File metadata and controls
34 lines (25 loc) · 785 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
32
33
34
const express = require('express');
const nunjucks = require('nunjucks');
const bodyParser = require('body-parser');
const morgan = require('morgan');
const routes = require('./routes');
const models = require('./models');
let app = express();
app.set('view engine', 'html');
app.engine('html', nunjucks.render);
nunjucks.configure('views', { noCache: true });
app.use(morgan('dev'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static('public'));
app.use('/jquery', express.static('node_modules/jquery/dist'))
app.use(routes);
app.use((err, req, res, next)=> {
res.render('error', { err });
})
let port = process.env.PORT || 3500;
models.sync()
.then(()=> {
app.listen(port, ()=> {
console.log(`listening on port ${port}`);
})
})