masasron / adonis-throttle

A rate limiter for Adonis JS
MIT License
64 stars 11 forks source link

Fix issue with ThrottleManager error thrown #12

Closed Barry-Fisher closed 5 years ago

Barry-Fisher commented 5 years ago

Fix issue with ThrottleManager so that module exports a constructed object similar to other core Adonis managers.

With InvalidArgumentException: E_INVALID_IOC_MANAGER: Make sure Adonis/Addons/Throttle does have a extend method.

This is because the this.app.manager in ThrottleProvider register() expects a function (i.e. a constructed class instance) This was already done in the following this.app.bind call.

This commit ensures the calls to this.app.manager and this.app.bind are the same functions by exporting new ThrottleManager() in Manager.js.

ThrottleManagerTest.js also adapted to inject the constructed manager function from Manager.js.