-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
42 lines (31 loc) · 949 Bytes
/
server.js
File metadata and controls
42 lines (31 loc) · 949 Bytes
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
import dotenv from "dotenv";
dotenv.config();
import path from "path";
import { fileURLToPath } from "url";
import "./src/models/index.js";
import cors from "cors";
import helmet from "helmet";
import rateLimit from "express-rate-limit";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
import express from "express";
const app = express();
app.use(helmet());
const limiter = rateLimit({
windowMs: 15 * 60 * 1000,
max: 100,
message: "Muitas requisições deste IP, tente novamente mais tarde.",
});
app.use(limiter);
app.use(express.json());
app.use(cors());
app.use("/files", express.static(path.resolve(__dirname, "uploads")));
const PORT = process.env.PORT || 3000;
import routes from "./src/routes/index.routes.js";
routes(app);
app.use("/", (req, res) => {
return res.json(`Servidor Online!`);
});
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});