A sqlite store for express-rate-limit
npm install rate-limit-sqliterate-limit-sqlite A SQLite store for theexpress-rate-limit
middleware.
From the npm registry:
``sh`Using npm
> npm install rate-limit-sqliteUsing yarn or pnpm
> yarn/pnpm add rate-limit-sqlite
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:
`ts`
import { SqliteStore } from 'rate-limit-sqlite'
`ts
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)RateLimit-*
standardHeaders: true, // Return rate limit info in the headersX-RateLimit-*
legacyHeaders: false, // Disable the 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)
`
#### 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`.
MIT © Srinivas Kolla