forked from burashka/Intranet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
28 lines (21 loc) · 731 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
const express = require('express');
const path = require('path');
const logger = require('morgan');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const sync = require('./routes/sync/sync');
const app = express();
function ensureSecure(req, res, next){
if(req.secure){
return next();
};
res.redirect('https://' + req.hostname + ":" + (process.env.HTTPS_PORT || 443) + req.url);
}
app.all('*', ensureSecure);
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/sync', sync);
module.exports = app;