-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (21 loc) · 848 Bytes
/
index.js
File metadata and controls
28 lines (21 loc) · 848 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
const express = require('express');
const cookieParser = require('cookie-parser');
const cors = require('cors');
const swaggerUi = require('swagger-ui-express');
const YAML = require('yamljs');
const swaggerDocument = YAML.load('../config/swagger.yaml');
const { AppError } = require('@utils/tdb_globalutils');
const PORT = 3005; // port
const app = express();
// CORS
app.use(cors());
// GLOBAL MIDDLEWARES
app.use(express.json()); // body parser (reading data from body to req.body)
app.use(cookieParser()); // cookie parser (reading data from cookie to req.cookie)
app.use('/v1/tezDeals-doc', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
app.all('*', (req, res, next) => {
next(new AppError(`can't find ${req.originalUrl} on this server`, 404));
});
app.listen(PORT, () => {
console.log(`Listening on Port ${PORT}`);
});