diff --git a/src/e2e-test.ts b/src/e2e-test.ts index 80fd6e7..c1290ff 100644 --- a/src/e2e-test.ts +++ b/src/e2e-test.ts @@ -5,13 +5,13 @@ import { Redis } from "ioredis"; import { config } from "./config"; import { JobJson, Queue } from "bullmq"; import { cleanCache } from "./utils/queue-factory"; -import { WorkerHttpController } from "./controllers/http/worker-http-controller"; const token = 'test-token'; describe("e2e", () => { - const queueName = 'testQueue-e2e'; + //test queue name with curly braces (Dragonfly way) + const queueName = '{testQueue-e2e}'; beforeAll(() => { mock.module('./config', () => ({ diff --git a/src/fetch-handler.ts b/src/fetch-handler.ts index 057e433..e8cbf5c 100644 --- a/src/fetch-handler.ts +++ b/src/fetch-handler.ts @@ -88,7 +88,7 @@ export const fetchHandler = ( } else if (route.httpHandler) { return route.httpHandler({ req, - params: cleanURI(route.params), + params: route.params, searchParams, redisClient: connection, workersRedisClient: workersConnection @@ -97,10 +97,3 @@ export const fetchHandler = ( return new Response("Not found", { status: 404 }); } } - -function cleanURI(params: Record) { - for (let [key, value] of Object.entries(params)) { - params[key] = decodeURI(value); - } - return params; -} diff --git a/src/utils/route-matcher.spec.ts b/src/utils/route-matcher.spec.ts index bcee37d..36d5aab 100644 --- a/src/utils/route-matcher.spec.ts +++ b/src/utils/route-matcher.spec.ts @@ -16,7 +16,7 @@ describe("RouteMatcher", () => { const result = matcher.match("/queues/test%20queue"); expect(result).toEqual({ name: "queueRoute", - params: { queueName: "test%20queue" }, + params: { queueName: "test queue" }, }); }); diff --git a/src/utils/router-matcher.ts b/src/utils/router-matcher.ts index ea1cbd9..380334a 100644 --- a/src/utils/router-matcher.ts +++ b/src/utils/router-matcher.ts @@ -1,5 +1,5 @@ import { WebSocketHandler } from "bun"; -import { HttpHandlerOpts } from "../interfaces/http-handler-opts"; +import { HttpHandlerOpts } from "../interfaces"; import { Cluster, Redis } from "ioredis"; type HttpHandler = (opts: HttpHandlerOpts) => Promise; @@ -80,7 +80,7 @@ export class RouteMatcher { if (matches && (!route.method || route.method === method)) { const params: { [key: string]: any } = {}; route.paramNames.forEach((param, index) => { - params[param] = matches[index + 1]; + params[param] = decodeURI(matches[index + 1]); }); const result: MatchResult = {