-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (24 loc) · 1.09 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
require("dotenv").config();
const cors = require("cors");
const express = require("express");
const app = express();
const userController = require("./controllers/userController");
const friendController = require("./controllers/friendController");
const searchController = require("./controllers/searchController");
const seasonController = require("./controllers/seasonController");
const showController = require("./controllers/showController");
const statController = require("./controllers/statController");
const { checkJwt } = require( "./middlewares/guard");
const cache = require("./middlewares/cache");
app.use(cors({
origins: [process.env.ORIGIN],
allowedHeaders: ["Authorization", "Content-Type"]
}));
app.use(express.json());
app.use("/users", checkJwt, userController);
app.use("/search", checkJwt, cache(3600, false), searchController);
app.use("/shows", checkJwt, showController);
app.use("/seasons", checkJwt, cache(3600, true), seasonController);
app.use("/stats", checkJwt, cache(60, true), statController);
app.use("/friends", checkJwt, friendController);
app.listen(process.env.PORT);