-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
42 lines (28 loc) · 955 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
42
const path = require('path')
const express = require('express')
const bodyParser = require('body-parser');
//const expressHbs = require('express-handlebars');
const app = express();
const errorController = require('./controllers/error');
const db = require('./util/database');
// app.engine('hbs', expressHbs({
// layoutsDir: 'views/layouts/',
// defaultLayout: 'main-layout',
// extname:'hbs'
// }));
// app.set('view engine', 'pug');
//app.set('view engine', 'hbs');
app.set('view engine', 'ejs');
app.set('views', 'views');
const adminRoutes = require('./routes/admin');
const shopRoutes = require('./routes/shop');
db.execute('select * from products').then().catch();
app.use(bodyParser.urlencoded({
extended: false
}));
app.use(express.static(path.join(__dirname, 'public')));
app.use('/admin', adminRoutes);
app.use(shopRoutes);
//app.use('/', errorController.get404);
app.use(errorController.get404);
app.listen(3000);