-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
44 lines (26 loc) · 927 Bytes
/
app.js
File metadata and controls
44 lines (26 loc) · 927 Bytes
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
const express = require('express');
const morgan = require('morgan')
const cors = require('cors')
require('dotenv').config()
const port = process.env.PORT || 3000;
const path = require('path');
const app = express();
const thirdPartyCors = process.env.THIRD_PARTY_CORS.split(' ');
let corsOptions = { origin: [...thirdPartyCors, 'http://localhost:3000'] }
console.log(corsOptions)
app.use(cors())
const webRouter = require('./web/webRoutes');
const apiRouter = require('./api/apiRoutes');
app.use(morgan('common'));
app.use(express.json()) // body parser: json
app.use(express.urlencoded({ extended: true })); // body prser: formdata
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(express.static('public'));
app.use('/api', apiRouter);
app.use('/', webRouter)
app.get('*', async (req, res) => {
let message
res.status(404).render('404')
})
module.exports = app