-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (27 loc) · 1.01 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
const express = require("express");
const path = require("path");
const cookieParser = require("cookie-parser");
const logger = require("morgan");
const app = express();
// routes
const coursesRouter = require("./app/courses/routes");
const mediaRouter = require("./app/media/routes");
const ordersRouter = require("./app/orders/routes");
const paymentsRouter = require("./app/payments/routes");
const usersRouter = require("./app/users/routes");
const refreshTokensRouter = require("./app/refreshTokens/routes");
app.use(logger("dev"));
app.use(express.json({ limit: "50mb" }));
app.use(express.urlencoded({ extended: false, limit: "50mb" }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, "public")));
// auth
const auth = require("./middleware/auth");
// url routes
app.use("/users", usersRouter);
app.use("/courses", auth, coursesRouter);
app.use("/media", mediaRouter);
app.use("/orders", ordersRouter);
app.use("/payments", paymentsRouter);
app.use("/tokens", refreshTokensRouter);
module.exports = app;