-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (28 loc) · 908 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
const express = require("express");
const path = require("path");
const cookieParser = require("cookie-parser");
const expressWs = require("express-ws");
const cors = require("cors");
const http = require("http");
const helmet = require("helmet");
const compression = require("compression");
const rateLimit = require("express-rate-limit");
const expressApp = express();
const server = http.createServer(expressApp);
require("dotenv").config();
const { app } = expressWs(expressApp, server);
const indexRouter = require("./routes/index.route");
const limiter = rateLimit({
windowMs: 1 * 60 * 1000,
max: 20,
});
app.use(limiter);
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(compression());
app.use(helmet());
app.use(cookieParser());
app.use(express.static(path.join(__dirname, "public")));
app.use("/", indexRouter);
module.exports = server;