-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (25 loc) · 828 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
const cors = require("cors");
const express = require("express");
const bodyParser = require("body-parser");
const { handleError } = require("./helpers/error");
const { generateDocs } = require("./docs");
const { checkUrl } = require("./middleware/origin");
const app = express();
var { PORT } = require("./config");
app.use(express.static(__dirname + "/public"));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cors());
app.options("*", cors());
app.get("/", (request, response) => {
response.send(generateDocs());
});
const previewController = require("./preview");
app.use("/api/v1", checkUrl, previewController);
app.use((err, req, res, next) => {
handleError(err, res);
});
const port = PORT || 80;
app.listen(port, () => {
console.log(`Running on port ${port}`);
});