-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
37 lines (33 loc) · 1.3 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
// const Koa = require('koa');
// const router = require('koa-router')();
// const bodyParser = require('koa-bodyparser');
// const staticFiles = require('koa-static');
const app = require('./express');
const bodyParser = require('body-parser');
const session = require('express-session');
const passport = require('passport');
const jsonwebtoken = require("jsonwebtoken");
const cookieParser = require('cookie-parser');
// const app = new Koa();
require('dotenv').config();
app.use(cookieParser());
app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
app.set('view engine', 'ejs');
app.use(app.express.static(__dirname + '/public'));
require("./server/app");
/*app.use(function(req, res, next) {
if (req.headers && req.headers.authorization && req.headers.authorization.split(' ')[0] === 'JWT') {
jsonwebtoken.verify(req.headers.authorization.split(' ')[1], 'Trainly', function(err, decode) {
if (err) req.user = undefined;
req.user = decode;
next();
});
} else {
req.user = undefined;
next();
}
});*/
app.listen(process.env.PORT || 8800, () => {
console.log(`server is running at localhost:${process.env.PORT || 8800}`);
});