-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.js
59 lines (47 loc) · 1.5 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
'use strict';
const http = require('http');
const bodyParser = require('body-parser');
const PORT = process.env.PORT || 3333;
const express = require('express');
const dotenv = require('dotenv');
dotenv.config();
const connectDB = require('./config/db.js');
connectDB();
const es6Renderer = require('express-es6-template-engine');
const cors = require('cors');
const corsOptions = {
origin: '*',
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
preflightContinue: false,
optionsSuccessStatus: 204,
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers':
'Origin, X-Requested-With, Content-Type, Accept',
};
const app = express();
const server = http.createServer(app);
app.engine('html', es6Renderer);
app.set('views', './views');
app.set('view engine', 'html');
app.use(express.static('public'));
app.use(bodyParser.json());
app.use(
bodyParser.urlencoded({
extended: false,
})
);
app.use(cors(corsOptions));
server.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});
app.get('/', (req, res) => {
res.send('API is running...');
});
const userController = require('./routes/userRoutes.js');
const teamController = require('./routes/teamRoutes.js');
const documentController = require('./routes/documentRoutes.js');
const getCardInfoController = require('./routes/getCardInfoRoutes.js');
app.use('/user', userController);
app.use('/team', teamController);
app.use('/document', documentController);
app.use('/getCardInfo', getCardInfoController);