-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (26 loc) · 967 Bytes
/
index.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
const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const app = express();
const errorMiddleware = require('./src/middleware/error');
// database config import
require('./src/config/mongo.config');
//swagger package import
const swaggerUi = require('swagger-ui-express');
const swaggerSpec = require('./src/docs/swaggerConfig');
// import all routes file
const authRoutes = require('./src/routes/auth.router');
const meRoutes = require('./src/routes/me.router');
// use middleware
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cors());
app.use(errorMiddleware);
// all routers
app.use('/auth', authRoutes);
app.use('/me', meRoutes);
// Swagger documentation
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));
app.listen(parseInt(process.env.PORT), () => {
console.log("🚀 ~ file: app listening on port ~ ", parseInt(process.env.PORT))
});