Skip to content

Add support for cost param #51

@marceloverdijk

Description

@marceloverdijk

It would be nice to have cost param like:

app.use(
  rateLimiter({
    windowMs: 15 * 60 * 1000, // 15 minutes
    limit: 100, // Limit each IP to 100 requests per `window` (here, per 15 minutes).
    standardHeaders: "draft-6", // draft-6: `RateLimit-*` headers; draft-7: combined `RateLimit` header
    keyGenerator: (c) => "<unique_key>", // Method to generate custom identifiers for clients.
    costCalculator: (c) => { return 2; }
  })
);

e.g. based on query params one could decide that the cost for a certain call is more expensive.
this cost should then be used in the counter.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions