1.0.12 • Published 3 years ago
nuxt-throttle-module v1.0.12
Nuxt Throttle Module
This module is designed to limit the number of requests made to the server from a single IP address and and the total number of participants for nuxt 2 and nuxt 3. It defines a Nuxt module that can be used in a Nuxt application.
The module requires Redis to work. See ENV for more information.
Quick Setup
- Add
nuxt-throttle-moduledependency to your project
# Using pnpm
pnpm add -D nuxt-throttle-module
# Using yarn
yarn add --dev nuxt-throttle-module
# Using npm
npm install --save-dev nuxt-throttle-module- Add
nuxt-throttle-moduleto themodulessection ofnuxt.config.ts
nuxt 3
export default defineNuxtConfig({
modules: [
'nuxt-throttle-module'
],
throttleModule: {
ipMaxCount: 200,
minuteMaxCount: 2000,
secondMaxCount: 20,
}
})nuxt 2
export default {
modules: [
'nuxt-throttle-module'
],
throttleModule: {
ipMaxCount: 200,
minuteMaxCount: 2000,
secondMaxCount: 20,
}
}That's it! You can now use My Module in your Nuxt app ✨
Options
The module accepts configuration options in the form of a TypeScript interface ModuleOptions. These options include:
ipMaxCount- the maximum number of requests that can be made from a single IP addressminuteMaxCount- the maximum number of requests that can be made in a minutesecondMaxCount- the maximum number of requests that can be made in a secondprefix- redis prefixtime- time for clean redis These options can be overridden when initializing the module.
ENV
- process.env.REDIS_HOST - redis host
- process.env.REDIS_PORT - redis port
