diff --git a/api/source/plausible.ts b/api/source/plausible.ts index 73845e179..1870cf444 100644 --- a/api/source/plausible.ts +++ b/api/source/plausible.ts @@ -44,6 +44,7 @@ export const plausibleMiddleware = async ( void plausibleEvent(ctx, { eventName: 'pageview' }).catch((err) => { const error = err as RequestError + // eslint-disable-next-line no-console console.error(error.code, error.message) }) @@ -56,6 +57,7 @@ export const plausibleMiddleware = async ( }, }).catch((err) => { const error = err as RequestError + // eslint-disable-next-line no-console console.error(error.code, error.message) }) diff --git a/api/source/rate-limiter.ts b/api/source/rate-limiter.ts index f6a2a06cb..1aa4ea7a0 100644 --- a/api/source/rate-limiter.ts +++ b/api/source/rate-limiter.ts @@ -1,5 +1,5 @@ import IORedis from 'ioredis' -import { BaseContext, Next } from 'koa' +import { BaseContext } from 'koa' import { RateLimiterMemory, RateLimiterRedis, @@ -23,7 +23,10 @@ const rateLimiter = duration: 1, // per 1 seconds }) -export const rateLimiterMiddleware = async (ctx: BaseContext, next: Next) => { +export const rateLimiterMiddleware = async ( + ctx: BaseContext, + next: () => Promise +) => { try { await rateLimiter.consume(ctx.ip) } catch (rejRes) { @@ -44,7 +47,7 @@ export const rateLimiterMiddleware = async (ctx: BaseContext, next: Next) => { return } - return (await next()) as unknown + return await next() } const isRateLimiterRes = (val: unknown): val is RateLimiterRes => {