-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
42 lines (26 loc) · 831 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
const express = require('express')
const app = express();
const favicon = require('serve-favicon');
app.use(favicon(__dirname + '/public/assets/favicon.ico'));
const serveStatic = require('serve-static')
app.use(
serveStatic('public', {
'index': ['index.html', 'index.htm'],
}
)
)
app.use(express.urlencoded({ extended: true }))
app.use(express.json())
session = require('./session')
app.use(session)
const initDb = require('./db.js')
const routes = require('./routes')
initDb()
.then(db => {
// Initialize the application once database connections are ready.
const server = routes(app, db).listen(3000, () => console.log('Listening on port 3000'))
}).catch(err => {
console.error('Failed to make all database connections!')
console.error(err)
process.exit(1)
})