-
Notifications
You must be signed in to change notification settings - Fork 26
/
server.js
36 lines (28 loc) · 982 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
const express = require('express')
const app = express();
const db = require('./db');
require('dotenv').config();
const passport = require('./auth');
const bodyParser = require('body-parser');
app.use(bodyParser.json()); // req.body
const PORT = process.env.PORT || 3000;
// Middleware Function
const logRequest = (req, res, next) => {
console.log(`[${new Date().toLocaleString()}] Request Made to : ${req.originalUrl}`);
next(); // Move on to the next phase
}
app.use(logRequest);
app.use(passport.initialize());
const localAuthMiddleware = passport.authenticate('local', {session: false})
app.get('/', function (req, res) {
res.send('Welcome to our Hotel');
})
// Import the router files
const personRoutes = require('./routes/personRoutes');
const menuItemRoutes = require('./routes/menuItemRoutes');
// Use the routers
app.use('/person', personRoutes);
app.use('/menu', menuItemRoutes);
app.listen(PORT, ()=>{
console.log('listening on port 3000');
})