-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
39 lines (28 loc) · 959 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
39
const express = require("express");
const cookieParser = require("cookie-parser");
const cors = require("cors");
const bodyParser = require("body-parser");
const logger = require("morgan");
const passport = require("passport");
const strategies = require("./shared/passport");
const errorHandler = require("./middlewares/error");
const swagger = require("./middlewares/swagger.js");
const routes = require("./routes/index");
var app = express();
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(logger("common"));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(passport.initialize());
passport.use("jwt", strategies.jwt);
app.use("/api", cors(), routes);
swagger.setup(app);
app.use(errorHandler.notFound);
app.use(errorHandler.validation);
app.use(errorHandler.handler);
const port = 3001;
app.listen(port);
module.exports = app;