-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
50 lines (40 loc) · 1.09 KB
/
server.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
'use strict';
const bodyParser = require('body-parser');
const cors = require('cors');
const express = require('express');
const favicon = require('serve-favicon');
const hbs = require('express-handlebars');
const path = require('path');
const volleyball = require('volleyball');
const config = require('./config');
const api = require('./routes');
const app = express();
app.use('/public', express.static(path.join(__dirname,'public')));
app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(bodyParser.urlencoded({
extended: false
}));
app.use(bodyParser.json());
app.use(volleyball);
app.use(cors());
app.engine('.hbs', hbs({
defaultLayout: 'default',
extname: '.hbs'
}));
app.set('view engine', '.hbs');
app.get('/', function (req, res) {
res.render('home');
});
app.get('/add', function (req, res) {
res.render('add-user');
});
app.use('/api', api);
config.DB_CONN.sync({
force: true
})
.then(() => {
console.log('Database connected');
app.listen(config.PORT, () => {
console.log('localhost server running on port:', config.PORT);
});
}).catch();