-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
42 lines (34 loc) · 1.12 KB
/
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 express = require('express');
const app = express();
const path = require('path');
const exphbs = require('express-handlebars');
const bodyParser = require('body-parser');
const sqlite3 = require('sqlite3').verbose();
// open database in memory
let db = new sqlite3.Database('./scoreboard', (err) => {
if (err) {
return console.error(err.message);
}
console.log('Connected to the in-memory SQlite database.');
});
// close the database connection
// db.close((err) => {
// if (err) {
// return console.error(err.message);
// }
// console.log('Close the database connection.');
// });
app.use(express.static(path.join(__dirname, 'public')));
app.engine('handlebars', exphbs({defaultLayout: 'index'}));
app.set('view engine', 'handlebars');
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
const main = require('./routes/home/index');
const admin = require('./routes/admin/index');
const register = require('./routes/admin/register');
app.use('/', main);
app.use('/admin', admin);
app.use('/register', register);
app.listen(9999, () => {
console.log('listening on port 9999');
});