Fix lint
parent
4d85612b2d
commit
1ae08b887e
|
@ -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)
|
||||
})
|
||||
|
||||
|
|
|
@ -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<unknown>
|
||||
) => {
|
||||
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 => {
|
||||
|
|
Loading…
Reference in New Issue