-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexp.js
31 lines (22 loc) · 940 Bytes
/
exp.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
const path = require('path')
const express = require('express')
const morgan = require('morgan')
const cookieParser = require('cookie-parser')
const cors = require('cors')
const exp = express()
const apiV1Url = process.env.API_V1_URL || 'api'
const apiV2Url = process.env.API_V2_URL || 'api/v2'
require('./config/database/mongoose')
exp.use(`/${apiV1Url}/views`, express.static('v1/views'))
exp.use(`/${apiV2Url}/views`, express.static(path.join(__dirname, 'v2/public')))
exp.use(`/${apiV2Url}/oauth/authorise`, express.static(path.join(__dirname, 'v2/oauth/views')))
exp.use(express.json())
exp.use(express.urlencoded({ extended: true }))
exp.use(morgan('dev'))
exp.use(cookieParser())
exp.use(cors())
exp.use(require('./v2/utils/middleware').setSecurityHeaders())
exp.use('/' + apiV1Url, require('./v1/routes/index'))
exp.use('/' + apiV2Url, require('./v2/routes/index'))
exp.use(require('./v1/routes/404'))
module.exports = exp