From f0aca17a0a9de5204cc26eb8f3dae4257175b210 Mon Sep 17 00:00:00 2001 From: Michael Wolf Date: Sun, 8 Feb 2026 13:57:41 -0500 Subject: [PATCH] Pass URL parameters from path-to-regexp match into Call.parameters Call.parameters was hardcoded to a placeholder object. Now the matched route parameters are threaded through from the dispatcher to the handler so handlers can access e.g. call.parameters.word. Co-Authored-By: Claude Opus 4.6 --- backend/diachron/app.ts | 2 +- backend/diachron/routing.ts | 3 ++- backend/diachron/types.ts | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/diachron/app.ts b/backend/diachron/app.ts index 5bad0cc..7cd220a 100644 --- a/backend/diachron/app.ts +++ b/backend/diachron/app.ts @@ -61,7 +61,7 @@ const makeApp = ({routes, processTitle}: MakeAppArgs) => { console.log("DEBUG: trying pattern, match result =", match); if (match) { console.log("match", match); - const resp = await pr.handler(req); + const resp = await pr.handler(req, match.params); return resp; } diff --git a/backend/diachron/routing.ts b/backend/diachron/routing.ts index 2535743..fbd33fc 100644 --- a/backend/diachron/routing.ts +++ b/backend/diachron/routing.ts @@ -29,6 +29,7 @@ const processRoutes=(routes:Route[]) :ProcessedRoutes => { const handler: InternalHandler = async ( expressRequest: ExpressRequest, + params: Record, ): Promise => { const method = massageMethod(expressRequest.method); @@ -47,7 +48,7 @@ const processRoutes=(routes:Route[]) :ProcessedRoutes => { pattern: route.path, path: expressRequest.originalUrl, method, - parameters: { one: 1, two: 2 }, + parameters: params, request: expressRequest, user: auth.user, session: new Session(auth.session, auth.user), diff --git a/backend/diachron/types.ts b/backend/diachron/types.ts index 2cb2b8d..ce8e9ab 100644 --- a/backend/diachron/types.ts +++ b/backend/diachron/types.ts @@ -29,13 +29,13 @@ export type Call = { pattern: string; path: string; method: Method; - parameters: object; + parameters: Record; request: ExpressRequest; user: User; session: Session; }; -export type InternalHandler = (req: ExpressRequest) => Promise; +export type InternalHandler = (req: ExpressRequest, params: Record) => Promise; export type Handler = (call: Call) => Promise; export type ProcessedRoute = {