-
Notifications
You must be signed in to change notification settings - Fork 1
/
server-config.js
41 lines (32 loc) · 1.17 KB
/
server-config.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
var express = require('express');
var partials = require('express-partials');
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var util = require('./lib/utility');
var handler = require('./lib/request-handler');
var app = express();
// app.set('port', (process.env.PORT || 5000));
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(partials());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(__dirname + '/public'));
app.use(cookieParser('shhhh, very secret'));
app.use(session({
secret: 'shhh, it\'s a secret',
resave: false,
saveUninitialized: true
}));
app.get('/', util.checkUser, handler.renderIndex);
app.get('/create', util.checkUser, handler.renderIndex);
app.get('/links', util.checkUser, handler.fetchLinks);
app.post('/links', handler.saveLink);
app.get('/login', handler.loginUserForm);
app.post('/login', handler.loginUser);
app.get('/logout', handler.logoutUser);
app.get('/signup', handler.signupUserForm);
app.post('/signup', handler.signupUser);
app.get('/*', handler.navToLink);
module.exports = app;