This repository has been archived by the owner on Apr 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
server.js
62 lines (48 loc) · 1.54 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const express = require('express')
, bodyParser = require('body-parser')
, session = require('express-session')
, passport = require('./auth/passporthandler')
, cookieParser = require('cookie-parser')
, cors = require('cors')
, db = require('./db/models').db;
var secrets;
try {
secrets = require('./secrets.json')
} catch (e) {
console.error('Create your own secrets file lazybones');
secrets = require('./secret-sample.json')
}
const app = express();
const apirouter = require('./routes/api')
, loginrouter = require('./routes/login')
, logoutrouter = require('./routes/logout')
, signuprouter = require('./routes/signup')
, authorizerouter = require('./routes/authorize')
, profilerouter = require('./routes/profile')
, unauthorizerouter = require('./routes/unauthorize')
const ensure = require('./auth/authutils');
app.set("view engine", 'hbs');
app.use(cors());
app.use(cookieParser(secrets.EXPRESS_SESSIONS_SECRET));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(session({
secret: secrets.EXPRESS_SESSIONS_SECRET,
resave: false,
saveUninitialized: false
}));
app.use(passport.initialize());
app.use(passport.session());
app.get('/', function (req, res) {
res.status(200).send({
running: true
})
});
app.use('/signup', signuprouter);
app.use('/login', loginrouter);
app.use('/profile', profilerouter);
app.use('/logout', logoutrouter);
app.use('/authorize', authorizerouter);
app.use('/unauthorize', unauthorizerouter);
app.use('/api', apirouter);
module.exports = app;