Skip to content

Commit

Permalink
[Task] #41 remove test code
Browse files Browse the repository at this point in the history
  • Loading branch information
Type-Style committed Feb 15, 2024
1 parent b4f99c5 commit cc6b8c3
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ require('module-alias/register');
import { config } from 'dotenv';
import express from 'express';
import toobusy from 'toobusy-js';
// import { rateLimit } from 'express-rate-limit';
// import { slowDown } from 'express-slow-down';
import compression from 'compression';
import helmet from 'helmet';
import hpp from 'hpp';
Expand All @@ -15,9 +13,6 @@ import readRouter from '@src/controller/read';
import path from 'path';
import logger from '@src/scripts/logger';

// console.log({ "status": 403, "name": "Error", "message": { "errors": [{ "type": "field", "msg": "Invalid value", "path": "user", "location": "query" }, { "type": "field", "msg": "is required", "path": "lat", "location": "query" }]}});
// console.log(JSON.stringify({ "status": 403, "name": "Error", "message": { "errors": [{ "type": "field", "msg": "Invalid value", "path": "user", "location": "query" }, { "type": "field", "msg": "is required", "path": "lat", "location": "query" }]}}, null, 2));

// configurations
config(); // dotenv

Expand All @@ -37,33 +32,16 @@ app.use((req, res, next) => { // clean up IPv6 Addresses
logger.error(message);
res.status(400).send(message);
}

})

// const slowDownLimiter = slowDown({
// windowMs: 1 * 60 * 1000,
// delayAfter: 5, // Allow 5 requests per 15 minutes.
// delayMs: (used) => (used - 5) * 1000, // Add delay after delayAfter is reached
// })

// const rateLimiter = rateLimit({
// windowMs: 1 * 60 * 1000,
// limit: 10, // Limit each IP per `window`
// standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers
// legacyHeaders: false, // Disable the `X-RateLimit-*` headers
// })

app.use(helmet({ contentSecurityPolicy: { directives: { "default-src": "'self'", "img-src": "*" } } }));
app.use(cache);
app.use(compression())
app.use(hpp());
app.use(function (req, res, next) { // limit request size limit when recieving data
if (!['POST', 'PUT', 'DELETE'].includes(req.method)) { return next(); }
getRawBody(req, { length: req.headers['content-length'], limit: '1mb', encoding: true },
function (err) {
if (err) { return next(err) }
next()
}
function (err) { if (err) { return next(err) } next() }
)
})

Expand Down

0 comments on commit cc6b8c3

Please sign in to comment.