-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
38 lines (32 loc) · 1002 Bytes
/
app.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
/***
* author: Tushar Bochare
* Email: mytusshar@gmail.com
*/
"use strict";
var app = require("express")();
var swaggerTools = require("swagger-tools");
var YAML = require("yamljs");
var cors = require('cors');
var auth = require("./api/helpers/auth");
var controller = require("./api/controllers/main-controller");
var swaggerConfig = YAML.load("./api/swagger/swagger-api.yaml");
swaggerTools.initializeMiddleware(swaggerConfig, function(middleware) {
//Serves the Swagger UI on /docs
app.use(cors());
// needs to go BEFORE swaggerSecurity
app.use(middleware.swaggerMetadata());
app.use(middleware.swaggerSecurity({
//manage token function in the 'auth' module
Bearer: auth.verifyToken
}));
var routerConfig = {
controllers: "./api/controllers",
useStubs: false
};
app.use(middleware.swaggerRouter(routerConfig));
app.use(middleware.swaggerUi());
app.listen(3000, function() {
console.log("Started server on port 3000");
controller.initDatabaseIfNotAlready();
});
});