-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (35 loc) · 1.08 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
const express = require("express");
app = express();
// Importing env from environment
const dotenv = require("dotenv");
dotenv.config();
// Enable CORS
var cors = require("cors");
const corsOptions = {
origin: ['https://nuwan.dev', 'http://localhost:8080'],
}
app.use(cors(corsOptions));
// Setup body parser
var bodyParser = require("body-parser");
app.use(bodyParser.json());
// Start mongodb connection
require("./db/connect");
// Start sync jobs
require("./cron/sync");
// Import controllers
require("./controllers/developer")(app);
require("./controllers/contact")(app);
// Serve Swagger UI
const swaggerUi = require('swagger-ui-express')
const swaggerFile = require('./swagger_output.json')
var swaggeOptions = {
customSiteTitle: "Dev Spy API by Nuwan",
explorer: false,
customCss: '.swagger-ui .topbar { display: none }'
};
app.use('/', cors(), swaggerUi.serve, swaggerUi.setup(swaggerFile, swaggeOptions))
// App start on PORT
app.listen(process.env.PORT || 5000);
console.log(
`Node server running on port http://${process.env.HOST}:${process.env.PORT || 5000}`
);