-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
64 lines (54 loc) · 1.94 KB
/
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
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
63
64
const express = require('express')
const cors = require('cors')({ origin: true, credentials: true })
const responseTime = require('response-time')
const passport = require('passport')
const session = require('express-session')
const cookieParser = require('cookie-parser')
require('dotenv').config()
const k8sHelpers = require('./service-library/helpers/k8s.helpers')
k8sHelpers.init()
const { envConstants } = require('./service-library/constants')
/* Init Strategy */
const init = require('./init/init')
init.defaultStrategy()
passport.serializeUser((user, done) => {
done(null, user)
})
passport.deserializeUser((obj, done) => {
done(null, obj)
})
const app = express()
app.use(cors)
app.use(
session({
secret: envConstants.JWT_SECRET,
resave: false,
saveUninitialized: false
})
)
app.use(passport.initialize())
app.use(cookieParser())
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
app.use(responseTime({ suffix: false, digits: 0 }))
/* Middlewares */
const callLoggerMiddleware = require('./service-library/middlewares/call-logger.middleware')
const listMiddleware = require('./service-library/middlewares/list.middleware')
const errorLoggerMiddleware = require('./service-library/middlewares/error-logger.middleware')
const cookieIdentityMiddleware = require('./service-library/middlewares/cookie-identity.middleware')
const providerMiddleware = require('./middlewares/provider.middleware')
app.use(callLoggerMiddleware)
app.use(providerMiddleware)
app.use(cookieIdentityMiddleware)
app.use(listMiddleware)
/* Routes */
const statusRoutes = require('./service-library/routes/status.routes')
const strategyRoutes = require('./routes/strategy.routes')
const authRoutes = require('./routes/auth.routes')
const userRoutes = require('./routes/user.routes')
app.use('/', statusRoutes)
app.use('/strategy', strategyRoutes)
app.use('/auth', authRoutes)
app.use('/user', userRoutes)
app.use(errorLoggerMiddleware)
module.exports = app