forked from anziosystems/gator-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
57 lines (49 loc) · 1.56 KB
/
app.ts
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
const express = require('express');
const cors = require('cors');
const app = express();
const authRoutes = require('./auth-routes');
const serviceRoutes = require('./service-routes');
const passport_setup = require('./passport-setup');
const cookieSession = require('cookie-session');
import {keys} from './keys';
const passport = require('passport');
const session = require('express-session');
app.set('view engine', 'ejs');
app.use(cors());
app.use(function(req: any, res: any, next: any) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, POST');
res.header('Access-Control-Max-Age', '10');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
next();
});
// app.use (cookieSession ({
// keys:keys.github.session.cookieKey,
// maxAge: 24*60*60*1000
// }));
app.use(
cookieSession({
key: 'git-user',
secret: keys.github.session.cookieKey,
cookie: {
maxAge: 24 * 60 * 60 * 1000, //1 day
secure: false, //https://stackoverflow.com/questions/11277779/passportjs-deserializeuser-never-called - didn't help though
},
httpOnly: false,
}),
);
app.use(session({secret: 'cats'}));
//initialize passport
app.use(passport.initialize());
app.use(passport.session());
app.use('/auth', authRoutes);
app.use('/service', serviceRoutes);
app.get('/', (req: any, res: any) => {
res.render('home');
});
app.get('/success', (req: any, res: any) => {
res.render('success');
});
app.listen(3000, () => {
console.log('listenting for request on port 3000');
});