Closed ShenQingchuan closed 5 years ago
/**
* Expose `ratelimit()`
*/
export default ratelimit;
so I turned my views into dist/index.js
// line 30:34
/**
* Expose `ratelimit()`
*/
exports.default = ratelimit;
module.exports = ratelimit;
exports.default
<= it seems like not a correct way for commonjs ??? ( I'm not quite sure about that ...)
I changed my dist/app.js :
//kapp.use(koa_simple_ratelimit_1.default({
// ^ with no .default call
kapp.use(koa_simple_ratelimit_1({
db: redis.createClient(),
duration: 30000,
max: 5
}));
Then my app runs correctly but I didn't check it this rate limiter works...
it was time to finally remove the baggage of the old export. Thanks for making this issue. This should be fixed in v4 https://github.com/scttcper/koa-simple-ratelimit/releases/tag/v4.0.0
And I also found something useful 👍
I checked those conversations in https://github.com/microsoft/TypeScript/issues/5565
and I'm now pretty sure about that the export
should be like that:
// if we use import like this:
import * as ratelimit from 'koa-simple-ratelimit'
// export shoud be :
export = ratelimit
those conversations in the typescript repository is very helpful and I really read them carefully in last few minutes...
it was time to finally remove the baggage of the old export. Thanks for making this issue. This should be fixed in v4 https://github.com/scttcper/koa-simple-ratelimit/releases/tag/v4.0.0
Would it be supported in npm ( I mean I can install v4.0.0 by npm/yarn ) soon?
I'm under China time now so it's already night now, it's time to sleep, I wish I can fix this in my app's runtime next morning LOL🤣 it's really a typescript's magical tour for me...
My Enviorment:
app.use(koa_simple_ratelimit_1.default({ ^ TypeError: koa_simple_ratelimit_1.default is not a function at Object. (/Users/macbook/Documents/Repository/DevLand/api.sicnurpz.online/dist/apiserver.js:29:40)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Issue May be caused by?
Due to this middleware installation failed, my koa app ran in crash...