-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (21 loc) · 650 Bytes
/
app.js
File metadata and controls
28 lines (21 loc) · 650 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 morgan = require("morgan");
const cors = require("cors");
const app = express();
const swaggerUi = require('swagger-ui-express');
const YAML = require('yamljs')
const apiDocs = YAML.load('./api-docs.yaml')
//Middleware
const notFoundHandler = require("./middleware/errors");
//Router
const indexRouter = require("./routes/index/index.router");
app.use(express.json());
app.use(morgan("dev"));
app.use(cors());
//API DOCS with Swagger
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(apiDocs))
//Routes
app.use("/", indexRouter);
// Routes Not found
app.use(notFoundHandler);
module.exports = app;