-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (27 loc) · 790 Bytes
/
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
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var routes = require('./routes');
var database = require('./controllers/database.js');
var session = require('express-session')({
secret: 'keyboard cat',
resave: true,
saveUninitialized: true
});
// Setup .env file:
require('dotenv').config({ path: 'vars.env' });
// Open database connection:
database.open();
// view engine setup:
app.set('views', 'views');
app.set('view engine', 'ejs');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static('public', { dotfiles: 'allow'}));
app.use(session);
// Use routes:
app.use('/', routes);
// Run:
app.listen(process.env.PORT, () => {
console.log('runs on port ' + process.env.PORT);
});