-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
37 lines (27 loc) · 890 Bytes
/
app.js
File metadata and controls
37 lines (27 loc) · 890 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
35
36
37
const path = require('path');
const express = require('express');
const adminData = require('./routes/admin');
const shopRoutes = require('./routes/shop');
const bodyParser = require('body-parser');
const errorController = require('./controllers/error');
const mongoConnect = require('./utils/database').mongoConnect
const User = require('./models/user')
const app = express();
app.set('view engine', 'ejs');
app.set('views', 'views');
app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static(path.join(__dirname, 'public')));
app.use((req, res, next) => {
User.findById('68b87a90331f6ab64607a3b3')
.then(user => {
req.user = user;
next();
})
.catch(err => console.log(err));
})
app.use('/admin', adminData.routes);
app.use(shopRoutes);
app.use(errorController.get404Page);
mongoConnect(() => {
app.listen(3000)
})