koajs / ratelimit

Rate limiter middleware
MIT License
485 stars 57 forks source link

fix default db bug when driver=memory #64

Closed lifeiFront closed 9 months ago

lifeiFront commented 3 years ago

In the configuration parameter, driver is "memory", db field does not pass the value. this.db = db | | new Map () ; // every request to create a Map object Limiting current is not going to work.

titanism commented 9 months ago

Hi there, thanks for your PR 👋

First, your PR adds unnecessary whitespace. Second this is expected behavior. You are supposed to create an instance, and then use that instance (which will use in-memory Map created already).