-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
35 lines (28 loc) · 906 Bytes
/
server.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
34
35
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
const express = require("express");
// const cors = require("cors");
const app = express();
// const corsOption = {
// origin: "http://localhost:8081",
// };
// app.use(cors(corsOption));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
const db = require("./models");
const swaggerUi = require("swagger-ui-express");
const YAML = require("yamljs");
// db.sequelize.sync();
db.sequelize.sync();
// db.sequelize.sync({
// force: true,
// });
app.get("/", (req, res) => {
res.json({ message: "Welcome to bezkoder application." });
});
const swaggerDocument = YAML.load("./swagger.yaml");
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
require("./routes/orders.routes")(app);
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`Server is running on port${PORT}.`);
});