Skip to content

Commit

Permalink
build(deps-dev): replace standard with neostandard
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Dec 8, 2024
1 parent 3c48b42 commit 35af4d3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![CI](https://github.com/fastify/fastify-rate-limit/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/fastify-rate-limit/actions/workflows/ci.yml)
[![NPM version](https://img.shields.io/npm/v/@fastify/rate-limit.svg?style=flat)](https://www.npmjs.com/package/@fastify/rate-limit)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)

A low overhead rate limiter for your routes.

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"type": "commonjs",
"types": "types/index.d.ts",
"scripts": {
"lint": "standard",
"lint:fix": "standard --fix",
"lint": "eslint",
"lint:fix": "eslint --fix",
"redis": "docker run -p 6379:6379 --name rate-limit-redis -d --rm redis",
"test": "npm run test:unit && npm run test:typescript",
"test:unit": "c8 --100 node --test",
Expand Down Expand Up @@ -36,8 +36,8 @@
"fastify": "^5.0.0",
"ioredis": "^5.4.1",
"knex": "^3.1.0",
"neostandard": "^0.11.9",
"sqlite3": "^5.1.7",
"standard": "^17.1.0",
"tsd": "^0.31.1"
},
"dependencies": {
Expand Down
8 changes: 4 additions & 4 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
preHandlerAsyncHookHandler,
RouteGenericInterface,
RouteOptions
} from 'fastify';
} from 'fastify'

declare module 'fastify' {
interface FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider> {
rateLimit<
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
ContextConfig = ContextConfigDefault,
SchemaCompiler extends FastifySchema = FastifySchema,
SchemaCompiler extends FastifySchema = FastifySchema
>(options?: fastifyRateLimit.RateLimitOptions): preHandlerAsyncHookHandler<
RawServer,
RawRequest,
Expand All @@ -32,7 +32,7 @@ declare module 'fastify' {
}
}

type FastifyRateLimit = FastifyPluginCallback<fastifyRateLimit.RateLimitPluginOptions>;
type FastifyRateLimit = FastifyPluginCallback<fastifyRateLimit.RateLimitPluginOptions>

declare namespace fastifyRateLimit {

Expand Down Expand Up @@ -144,5 +144,5 @@ declare namespace fastifyRateLimit {
export { fastifyRateLimit as default }
}

declare function fastifyRateLimit(...params: Parameters<FastifyRateLimit>): ReturnType<FastifyRateLimit>
declare function fastifyRateLimit (...params: Parameters<FastifyRateLimit>): ReturnType<FastifyRateLimit>
export = fastifyRateLimit
18 changes: 9 additions & 9 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import fastify, {
} from 'fastify'
import * as http2 from 'http2'
import { default as ioredis } from 'ioredis'
import pino from 'pino';
import pino from 'pino'
import fastifyRateLimit, {
errorResponseBuilderContext,
FastifyRateLimitOptions,
Expand All @@ -16,15 +16,16 @@ import fastifyRateLimit, {
} from '..'

class CustomStore implements FastifyRateLimitStore {
constructor(options: FastifyRateLimitOptions) {}
incr(
constructor (options: FastifyRateLimitOptions) {}
incr (
key: string,
callback: (
error: Error | null,
result?: { current: number; ttl: number }
) => void
) {}
child(routeOptions: RouteOptions & { path: string; prefix: string }) {

child (routeOptions: RouteOptions & { path: string; prefix: string }) {
return <CustomStore>(<FastifyRateLimitOptions>{})
}
}
Expand All @@ -49,13 +50,13 @@ const options1: RateLimitPluginOptions = {
if (context.ban) {
return {
statusCode: 403,
error: "Forbidden",
error: 'Forbidden',
message: `You can not access this service as you have sent too many requests that exceed your rate limit. Your IP: ${req.ip} and Limit: ${context.max}`,
}
} else {
return {
statusCode: 429,
error: "Too Many Requests",
error: 'Too Many Requests',
message: `You hit the rate limit, please slow down! You can retry in ${context.after}`,
}
}
Expand Down Expand Up @@ -144,7 +145,7 @@ const options9: RateLimitPluginOptions = {
appWithImplicitHttp.register(fastifyRateLimit, options1)
appWithImplicitHttp.register(fastifyRateLimit, options2)
appWithImplicitHttp.register(fastifyRateLimit, options5)
appWithImplicitHttp.register(fastifyRateLimit,options9)
appWithImplicitHttp.register(fastifyRateLimit, options9)

appWithImplicitHttp.register(fastifyRateLimit, options3).then(() => {
const preHandler1: preHandlerAsyncHookHandler = appWithImplicitHttp.rateLimit()
Expand All @@ -160,7 +161,7 @@ appWithImplicitHttp.register(fastifyRateLimit, options3).then(() => {
// })
})

appWithImplicitHttp.get('/', { config: { rateLimit: { max: 10, timeWindow: "60s" } } }, () => { return "limited" })
appWithImplicitHttp.get('/', { config: { rateLimit: { max: 10, timeWindow: '60s' } } }, () => { return 'limited' })

const appWithHttp2: FastifyInstance<
http2.Http2Server,
Expand All @@ -176,7 +177,6 @@ appWithHttp2.register(fastifyRateLimit, options7)
appWithHttp2.register(fastifyRateLimit, options8)
appWithHttp2.register(fastifyRateLimit, options9)


appWithHttp2.get('/public', {
config: {
rateLimit: false
Expand Down

0 comments on commit 35af4d3

Please sign in to comment.