rate-limit-sqlite
v0.0.2
Published
A sqlite store for express-rate-limit
Readme
rate-limit-sqlite
A SQLite store for the
express-rate-limit
middleware.
Installation
From the npm registry:
# Using npm
> npm install rate-limit-sqlite
# Using yarn or pnpm
> yarn/pnpm add rate-limit-sqliteUsage
Importing
This package is pure ESM. Please read this article for a guide on how to ensure your project can import this library.
This package requires you to use Node 22 or above.
Import it in a ESM project (type: module in package.json) as follows:
import { SqliteStore } from 'rate-limit-sqlite'Examples
import { rateLimit } from 'express-rate-limit'
import { SqliteStore } from 'rate-limit-sqlite'
// Create and use the rate limiter
const limiter = rateLimit({
// Rate limiter configuration
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // Limit each IP to 100 requests per `window` (here, per 15 minutes)
standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers
legacyHeaders: false, // Disable the `X-RateLimit-*` headers
// SQLite store configuration
store: new SqliteStore({
location: "..." // Path to database file on disk
prefix: "..." // Prefix for each key to store in database
}),
})
app.use(limiter)Configuration
location
string|undefined
The path to the database file on disk. Use :memory: or omit the option to use an in-memory SQLite database instead.
Defaults to :memory:.
prefix
string|undefined
The text to prepend to the key in the database.
Defaults to def.
License
MIT © Srinivas Kolla
