forked from WDI-DTLA-41/project_02_crud_app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
40 lines (36 loc) · 1.06 KB
/
Copy pathapp.js
File metadata and controls
40 lines (36 loc) · 1.06 KB
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
require('dotenv').config();
const express = require('express');
const favicon = require('serve-favicon');
const bodyParser = require('body-parser');
const session = require('express-session');
const hbs = require('express-handlebars');
const morgan = require('morgan');
const path = require('path');
const app = express();
// CONFIG
require('./db/config');
app.use(morgan('dev'));
app.use('/public', express.static(path.join(__dirname, 'public')));
app.use(favicon(path.join(__dirname, 'public/favicon.ico')));
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: true
}));
app.engine('hbs', hbs({
extname: 'hbs',
defaultLayout: 'main',
layoutsDir: path.join(__dirname, 'views/layouts/')
}));
app.set('view engine', 'hbs');
// ROUTES
app.use('/', require('./routes/index'));
app.use('/auth', require('./routes/auth'));
app.use('/profile', require('./routes/profile'));
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`Listening on ${port}`);
});