-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
32 lines (25 loc) · 814 Bytes
/
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
import express from 'express';
import dotenv from 'dotenv';
import bodyParser from 'body-parser';
import cors from 'cors';
import publicRoutes from './src/routes/public';
import apiRoutes from './src/routes/api';
import adminRoutes from './src/routes/admin';
import apiMiddleware from './src/middleware/apiTravelerAuth';
import adminMiddleware from './src/middleware/adminAuth';
import errorHandler from './src/middleware/errorHandler';
dotenv.config();
require('./src/config/sequelize');
const app = express();
app.use(
bodyParser.urlencoded({
extended: true,
}),
);
app.use(cors());
app.use(bodyParser.json());
app.use('/api/auth', publicRoutes);
app.use('/api/user', apiMiddleware, apiRoutes);
app.use('/api/admin', adminMiddleware, adminRoutes);
app.use(errorHandler);
module.exports = app;