-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
66 lines (55 loc) · 1.55 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const express = require("express");
const app = express();
const morgan = require("morgan");
const cookieParser = require("cookie-parser");
const fileUpload = require("express-fileupload");
//swagger documentation
const swaggerUi = require("swagger-ui-express");
const YAML = require("yamljs");
const swaggerDocument = YAML.load("./swagger.yaml");
//oauth
const passportConfig = require("./passport/passport");
const passport = require("passport");
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
//regular middlewares
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
//cookie and filkeupload
app.use(cookieParser());
app.use(
fileUpload({
useTempFiles: true,
tempFileDir: "/tmp/",
})
);
//temp check
app.set("view engine", "ejs");
app.use(morgan("tiny"));
const session = require("express-session");
app.use(
session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: false,
})
);
app.use(passport.initialize());
app.use(passport.session());
//routes
const home = require("./routes/home");
const user = require("./routes/user");
const product = require("./routes/product");
const auth = require("./routes/auth");
const payment = require("./routes/payment");
const order = require("./routes/order");
//router middlewares
app.use("/api/v1", home);
app.use("/api/v1", user);
app.use("/api/v1", product);
app.use("/auth", auth);
app.use("/api/v1", payment);
app.use("/api/v1", order);
app.use("/signuptest", (req, res) => {
res.render("signuptest");
});
module.exports = app;