-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
54 lines (35 loc) · 1.1 KB
/
index.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
43
44
45
46
47
48
49
50
51
52
53
54
const express = require('express');
const path = require('path');
const exphbs = require('express-handlebars');
const bodyParser = require('body-parser');
const session = require('express-session');
const fileupload = require('express-fileupload');
const busboy = require('express-busboy');
const cors = require('cors');
const app = express();
const main = require('./routes/main');
const admin = require('./routes/admin');
const user = require('./routes/user');
app.engine('hbs', exphbs({
defaultLayout: 'main',
extname: '.hbs'
}));
app.set('view engine', 'hbs');
app.set('views', path.join(__dirname, 'views'));
app.use(fileupload({createParentPath:true}));
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(session({
secret: 'secret',
resave: false,
saveUninitialized: false
}));
app.use("/admin", admin);
app.use("/user", user);
app.use("/", main);
app.use('/', express.static(path.join(__dirname, "/public")));
app.use('/user', express.static(path.join(__dirname, "/public")));
app.listen(1234, () => {
console.log("server is running");
});