Closed fzn0x closed 4 months ago
Were any migrations required in your DB to use @acpr/rate-limit-postgresql
?
I am not sure, why you are receiving this error. When I try it, it works as normal (other than the type error, which I believe you already know #10).
keyGenerator
function to () => "Hello"
, to make it static for testingpnpm@8.10.5
, node@19.7.0
, hono@4.2.8
with @hono/node-server@1.11.1
Seems to be working fine. If you are still getting any errors, can you share a reproduction?
Great answer but I decide to move to Redis instead and it's working fine, thanks for your attention @MathurAditya724.
This issue may be useful for someone later, but I close it as not planned for now.
Step to reproduce: try to use the @acpr/rate-limit-postgresql store
Started server http://localhost:3000 2 | 3 | Object.defineProperty(exports, '__esModule', { value: true }); 4 | 5 | var factory = require('hono/factory'); 6 | 7 | const getResetSeconds=(resetTime,windowMs)=>{let resetSeconds;if(resetTime){const deltaSeconds=Math.ceil((resetTime.getTime()-Date.now())/1e3);resetSeconds=Math.max(0,deltaSeconds);}else if(windowMs){resetSeconds=Math.ceil(windowMs/1e3);}return resetSeconds};const setDraft6Headers=(context,info,windowMs)=>{if(context.finalized)return;const windowSeconds=Math.ceil(windowMs/1e3);const resetSeconds=getResetSeconds(info.resetTime);context.header("RateLimit-Policy",
${info.limit};w=${windowSeconds}
);context.header("RateLimit-Limit",info.limit.toString());context.header("RateLimit-Remaining",info.remaining.toString());if(resetSeconds)context.header("RateLimit-Reset",resetSeconds.toString());};const setDraft7Headers=(context,info,windowMs)=>{if(context.finalized)return;const windowSeconds=Math.ceil(windowMs/1e3);const resetSeconds=getResetSeconds(info.resetTime,windowMs);context.header("RateLimit-Policy",${info.limit};w=${windowSeconds}
);context.header("RateLimit",`limit=${info.limit}, remaining=${info.remaining} | ... truncatedTypeError: resetTime.getTime is not a function. (In 'resetTime.getTime()', 'resetTime.getTime' is undefined) at getResetSeconds (D:\number-website\node_modules\hono-rate-limiter\index.cjs.js:7:107) at setDraft6Headers (D:\number-website\node_modules\hono-rate-limiter\index.cjs.js:7:400) at D:\number-website\node_modules\hono-rate-limiter\index.cjs.js:13:1650