-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
51 lines (32 loc) · 1018 Bytes
/
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
//Name: Omar Bafagih
//Student ID: 101209028
const express = require('express');
const app = express();
const PORT = process.env.PORT || 5000;
//SHOULD HAVE THE FOLLOWING COLLECTIONS ON MY DB:
// -- sessions
// -- orders
// -- users
//routers
const livegamesRouter = require('./routers/livegamesRouter');
//const ordersRouter = require('./routers/orders-router');
//setting up middleware
const path = require('path');
app.set('views', path.join(__dirname, '/views'));
app.set('view engine', 'pug');
app.use(express.static(path.join(__dirname, "public")));
app.use(express.json());
app.use(express.urlencoded({extended: true}));
app.use(function(req, res, next){
console.log(`${req.method} for ${req.url}`);
next();
});
//server routes
//routes using routers
app.use('/livegames',livegamesRouter);
//app.use('/orders', ordersRouter);
//session/authentication routes
app.get('/', function (req, res){
res.render('index');
});
app.listen(PORT, () => "Server listening on port 5000");