one question, to run Hono I need to install bun? Because I just installed Node, not even Bun
one question, to run Hono I need to install bun? Because I just installed Node, not even Bun

dev
wrangler dev
WorkerKV for some experiment and this is my codeexpiration props again?this.windowMs = 60_000 // 1 minuteelse clause. Try the followingexpiration (seconds since the epoch) or expirationTtl (seconds from now) ? Because I saw your this.windowMs = 60_000 // 1 minute comment, but you also have expirationTtl: this.windowMs and that would be wrong; it would be 60000 seconds.totalHits but the expiration time remains that same, thats why it is stored in resetTime. So when I am updating it, I am passing the expiration again.As of January 2022, expiration targets that are less than 60 seconds into the future are not supported. This is true for both expiration methods.
expiration attribute?expiration?WorkerKVexpirationexpirationexpirationexpirationexpirationthis.windowMs = 60_000 // 1 minutethis.windowMs = 60_000 // 1 minuteelseexpirationTtlexpirationTtl: this.windowMstotalHitsresetTimeawait this.namespace.put(keyWithPrefix, JSON.stringify(payload), {
expiration: Math.floor(payload.resetTime.getTime() / 1000),
});async increment(key: string): Promise<ClientRateLimitInfo> {
const keyWithPrefix = this.prefixKey(key);
// @ts-ignore
let payload: Required<ClientRateLimitInfo> = await this.namespace.get<Required<ClientRateLimitInfo>>(
keyWithPrefix,
"json",
);
const wasCreated = payload != null
if (wasCreated) payload = {
totalHits: payload.totalHits + 1,
resetTime: new Date(payload.resetTime),
};
else
payload = {
totalHits: 1,
resetTime: new Date(Date.now() + this.windowMs),
};
console.log("Payload - ", payload, " Expire - ", payload.resetTime.toLocaleString(), " Current - ", new Date().toLocaleString())
await this.namespace.put(keyWithPrefix, JSON.stringify(payload), {
expiration: !wasCreated ? Math.floor(payload.resetTime.getTime() / 1000) : undefined,
// expirationTtl: this.windowMs
});
return payload;
}const payload = wasCreated
? {
totalHits: payload.totalHits + 1,
resetTime: new Date(payload.resetTime)
}
: {
totalHits: 1,
resetTime: new Date(Date.now() + this.windowMs),
}if (wasCreated) {
payload = {
totalHits: payload.totalHits + 1,
resetTime: new Date(payload.resetTime),
}; // <-- semicolon here
} else { // <-- not here
payload = {
totalHits: 1,
resetTime: new Date(Date.now() + this.windowMs),
};
}const defaultPayload = {
hits: 1,
expiration: new Date(new Date().getTime() + 60_000),
}
const record = await env.NAMESPACE.get('key', { type: 'json' })
const payload = {
...defaultPayload,
...(record ?? {}), // if record is nullish, spread an empty object in its place
}
await env.NAMESPACE.put('key', payload, { expiration: payload.expiration })