-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
42 lines (34 loc) · 1.13 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
const express = require('express');
const app = express();
const PORT = 3000;
const bodyParser = require('body-parser')
const methodOverride = require('method-override')
const session = require('express-session')
//DB CONNECTION
require('./db/db')
//MIDDLEWARE
// app.use((req, res, next) => {
// console.log("MIDDLEWARE---every route passes thru here");
// next();
// })
app.use(bodyParser.urlencoded({extended: true}));
app.use(methodOverride('_method'));
app.use(session({
secret: "THIS IS A GOVERNMENT STRING GOOD ENOUGH FOR GOVERNMENTWORK",
resave: false,
saveUninitialized: false // legal
}))
//CONTROLLERS
const sandwichController = require('./controllers/sandwichController')
app.use('/sandwiches', sandwichController)
const ingredientController = require('./controllers/ingredientController')
app.use('/ingredients', ingredientController)
const authController = require('./controllers/authController')
app.use('/auth', authController)
// default
app.get('/', (req, res) => {
res.send('whatchadoin');
})
app.listen(PORT, () => {
console.log((new Date(Date.now())).toLocaleTimeString() + ': app listening on port ' + PORT);
})