We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
fromRequest
1 parent e31a2ec commit 9d2924dCopy full SHA for 9d2924d
src/zap.ts
@@ -307,11 +307,11 @@ function isReadableStream(val: unknown): val is Readable {
307
export function fromRequest<Fn extends (req: ServerRequest, ...rest: any[]) => any>(fn: Fn): Fn {
308
const cache = new WeakMap<ServerRequest, any>()
309
const errorCache = new WeakMap<ServerRequest, any>()
310
- const cachedFn = (req: ServerRequest) => {
+ const cachedFn = (req: ServerRequest, ...rest: any[]) => {
311
if (errorCache.has(req)) throw errorCache.get(req)
312
if (cache.has(req)) return cache.get(req)
313
try {
314
- const value = fn(req)
+ const value = fn(req, ...rest)
315
cache.set(req, value)
316
return value
317
} catch (error) {
0 commit comments