Skip to content

Commit

Permalink
nono is a bad dev :)
Browse files Browse the repository at this point in the history
  • Loading branch information
TeddyRoncin committed May 16, 2024
1 parent 9548033 commit 05cd51c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion web/src/apiRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ apiRouter.post("/sesame", async (request: Request, response: Response) => {
apiRouter.get("/ping", async (request: Request, response: Response) => {
const interval: number = Number(request.body.interval) || undefined;
setLastTimeChestWasAlive(Date.now(), interval);
logger.info("Chest pinged");
logger.info(`Chest pinged. Next ping in ${interval}`);
return response.status(200).send("Good news ! (Me too)");
});

Expand Down
23 changes: 7 additions & 16 deletions web/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import compression from "compression";
dotenv.config();
const app = express();

// Rate limit
app.use(rateLimit({
windowMs: 10 * 1000, // 10 seconds
max: 15, // limit each IP to 15 requests per windowMs
standardHeaders: 'draft-7',
}));

if (process.env.SENTRY_DSN) {
// Initiate Sentry
Sentry.init({
Expand All @@ -25,9 +32,6 @@ if (process.env.SENTRY_DSN) {
}
app.engine('html', ejs.renderFile);

// Enable morgan logger
// app.use(morgan());

// Enable compression
app.use(compression());

Expand All @@ -42,17 +46,4 @@ app.use(urlencoded({ extended: true }));
app.use(process.env.API_PREFIX, apiRouter);
app.use("", webRouter);

// Rate limit
app.use(rateLimit({
windowMs: 10 * 1000, // 10 seconds
max: 15, // limit each IP to 15 requests per windowMs
standardHeaders: 'draft-7',
}));

// Not found
// app.use((request: Request, response: Response) => notFound(response, Error.RouteNotFound));

// Error Handles
// app.use(errorHandler);

export default app;

0 comments on commit 05cd51c

Please sign in to comment.