-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
47 lines (40 loc) · 1.22 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict';
const express = require('express'),
app = express(),
session = require('express-session'),
RedisStore = require('connect-redis')(session),
SESS_SECRET = process.env.SESS_SECRET || 'DevPasswordYo',
REDIS_URL = process.env.REDIS_URL || 'redis://localhost:6379';
app.use(session({
secret: SESS_SECRET,
resave: false,
saveUninitialized: true,
store: new RedisStore({
url: REDIS_URL
})
}));
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
const apiR = require('./routes/api');
app.use(apiR);
const path = require('path'),
nodeSass = require('node-sass-middleware');
app.use(nodeSass({
src: path.join(__dirname, 'public'),
dest: path.join(__dirname, 'public'),
indentedSyntax: true,
sourceMap: true
}));
app.use(express.static(path.join(__dirname, 'public')));
app.get('*', (req, res) => {
res.send('You found the marble in the oatmeal!');
});
const db = require('./models/'),
localPort = 3000,
PORT = process.env.PORT || localPort;
db.sequelize.sync().then(() => {
app.listen(PORT, () => {
console.log(`Listening on port ${PORT}`); // eslint-disable-line no-console
});
});