Skip to content

Commit

Permalink
get all that app.use shit in there
Browse files Browse the repository at this point in the history
  • Loading branch information
Ianyourgod committed Mar 2, 2024
1 parent 024d113 commit 0ba4015
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions api/core.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
const bodyParser = require('body-parser');
const cors = require('cors');
const path = require('path');
const rateLimit = require('express-rate-limit');
const express = require("express");
const v1Router = require("./v1/routes");

const app = express();
const PORT = process.env.PORT || 3000;

app.use(cors({
origin: '*',
optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
}));
app.use(bodyParser.urlencoded({
limit: process.env.ServerSize,
extended: false
}));
app.set('trust proxy', 1);
app.use(rateLimit({
validate: {
trustProxy: true,
xForwardedForHeader: true,
},
windowMs: 5000, // 150 requests per 5 seconds
limit: 150,
standardHeaders: 'draft-7',
legacyHeaders: false,
}));

app.use("/api/v1", v1Router);

app.listen(PORT, () => {
Expand Down

0 comments on commit 0ba4015

Please sign in to comment.