From a58adcadf1087cb6d858b90647611fba57fcfa76 Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Wed, 30 Aug 2023 21:43:42 +0800 Subject: [PATCH] add rateLimiter to prediction --- packages/server/src/index.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index f6df0c30..b72cbaa1 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -660,9 +660,14 @@ export class App { // ---------------------------------------- // Send input message and get prediction result (External) - this.app.post('/api/v1/prediction/:id', upload.array('files'), async (req: Request, res: Response) => { - await this.processPrediction(req, res, socketIO) - }) + this.app.post( + '/api/v1/prediction/:id', + upload.array('files'), + (req: Request, res: Response, next: NextFunction) => getRateLimiter(req, res, next), + async (req: Request, res: Response) => { + await this.processPrediction(req, res, socketIO) + } + ) // Send input message and get prediction result (Internal) this.app.post('/api/v1/internal-prediction/:id', async (req: Request, res: Response) => { @@ -765,7 +770,6 @@ export class App { '/api/v1/rate-limit/:id', upload.array('files'), (req: Request, res: Response, next: NextFunction) => getRateLimiter(req, res, next), - // specificRouteLimiter, async (req: Request, res: Response) => { res.send("you're fine") }