✨ add throttle middleware
Create throttling on middleware to pause requests until a specified time before continuing. (default time 2s)
This commit is contained in:
6
src/middleware/system/throttle.middleware.ts
Normal file
6
src/middleware/system/throttle.middleware.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import Elysia from "elysia";
|
||||
|
||||
export const throttleMiddleware = (delayMs = 2000) => (app: Elysia) =>
|
||||
app.onRequest(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
||||
});
|
||||
Reference in New Issue
Block a user