0.46.0 • Published 10 months ago

@lidofinance/next-ip-rate-limit v0.46.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@lidofinance/next-ip-rate-limit

IP rate limit for next server api requests.

Installation

yarn add @lidofinance/next-ip-rate-limit.

Getting started

With Next.js API

import { ipRateLimit } from '@lidofinance/next-ip-rate-limit'
import { NextApiRequest, NextApiResponse } from 'next'

// env vars
const RATE_LIMIT = 60
const RATE_LIMIT_TIME_FRAME = 60 // 1 min

const someRequest = async (req, res) => {
  ipRateLimit({
    req,
    res,
    limit: RATE_LIMIT,
    timeFrame: RATE_LIMIT_TIME_FRAME,
  })

  await fetch()
}

export default someRequest

With @lidofinance/next-api-wrapper

import { wrapRequest, API } from '@lidofinance/next-api-wrapper'
import { ipRateLimit, rateLimitWrapper } from '@lidofinance/next-ip-rate-limit'

const someRequest: API = async (req, res) => await fetch()

export const rateLimit = rateLimitWrapper({ rateLimit: RATE_LIMIT, rateLimitTimeFrame: RATE_LIMIT_TIME_FRAME })

export default wrapRequest([rateLimit, someWrapper])(someRequest)
0.46.0

10 months ago

0.45.1

10 months ago

0.44.0

11 months ago

0.45.0

11 months ago

0.43.0

1 year ago

0.42.0

1 year ago

0.41.0

1 year ago

0.40.0

1 year ago

0.39.1

2 years ago

0.39.0

2 years ago

0.38.0

2 years ago

0.37.1

2 years ago

0.37.0

2 years ago

0.36.0

2 years ago

0.35.0

2 years ago

0.34.0

2 years ago

0.33.0

2 years ago

0.32.0

2 years ago

0.31.0

2 years ago

0.30.0

2 years ago

0.29.0

2 years ago

0.28.0

2 years ago

0.21.0

2 years ago

0.27.0

2 years ago

0.26.0

2 years ago

0.25.0

2 years ago

0.24.0

2 years ago

0.23.0

2 years ago

0.22.0

2 years ago

0.20.0

2 years ago

0.19.0

2 years ago

0.17.0

2 years ago

0.18.0

2 years ago

0.14.0

2 years ago

0.15.0

2 years ago

0.16.0

2 years ago

0.13.0

2 years ago

0.12.0

3 years ago

0.11.0

3 years ago

0.10.0

3 years ago