-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
40 lines (34 loc) · 1 KB
/
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
36
37
38
39
40
const express = require("express");
const routes = require("./routes");
const cors = require("cors");
var morgan = require("morgan");
// import sequelize connection
const sequelize = require("./config/connection.js");
const app = express();
const swaggerUi = require("swagger-ui-express");
const swaggerDocument = require("./swagger");
const PORT = 8080;
const HOST = "0.0.0.0";
const BASE_URL = process.env.BASE_URL || "";
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors());
app.use(morgan("combined"));
var options = {
explorer: true,
servers: [{
url: `https://${HOST}:${PORT}${BASE_URL}`,
}, ],
};
app.use(
BASE_URL + "/api-docs",
swaggerUi.serve,
swaggerUi.setup(swaggerDocument, options)
);
app.use(BASE_URL, routes);
// Sync Sequelize models to the MySQL database on server start
sequelize.sync({ force: false }).then(() => {
app.listen(PORT, HOST, () => {
console.log(`Running on http://${HOST}:${PORT}${BASE_URL}`);
});
});