-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
41 lines (28 loc) · 893 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
39
40
41
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const mongoConnect = require('./util/database').mongoConnect;
const adminRoutes = require('./routes/admin');
const shopRoutes = require('./routes/shop');
const User = require('./models/user');
const errorsController = require('./controllers/errors');
const app = express();
app.set('view engine', 'ejs');
app.set('views', 'views')
app.use((req, res, next) => {
User
.findById('5dc707d38469149aedfff416')
.then(user => {
req.user = new User(user);
next();
})
.catch(err => console.log({ err }));
});
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
app.use('/admin', adminRoutes);
app.use(shopRoutes);
app.use(errorsController.get404);
mongoConnect(() => {
app.listen(3000);
});