From 9d2924d06feab6d43b4c61a10e071ea5e4f88f80 Mon Sep 17 00:00:00 2001 From: Jacob Gillespie Date: Wed, 2 Mar 2022 13:19:00 +0000 Subject: [PATCH] Pass arguments to `fromRequest` wrapped function --- src/zap.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zap.ts b/src/zap.ts index a92dc1c..c1debe1 100644 --- a/src/zap.ts +++ b/src/zap.ts @@ -307,11 +307,11 @@ function isReadableStream(val: unknown): val is Readable { export function fromRequest any>(fn: Fn): Fn { const cache = new WeakMap() const errorCache = new WeakMap() - const cachedFn = (req: ServerRequest) => { + const cachedFn = (req: ServerRequest, ...rest: any[]) => { if (errorCache.has(req)) throw errorCache.get(req) if (cache.has(req)) return cache.get(req) try { - const value = fn(req) + const value = fn(req, ...rest) cache.set(req, value) return value } catch (error) {