diff --git a/src/api/index.ts b/src/api/index.ts index 7545f3a7..9839ab4b 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -125,7 +125,11 @@ async function loadRoutes(): Promise { methods: module.methods ?? defaultMethods } - if (pathname instanceof RegExp) { + if (module.paths && module.paths.length > 0) { + for (const explicitPath of module.paths) { + staticRoutes.set(explicitPath, routeData) + } + } else if (pathname instanceof RegExp) { dynamicRoutes.push([pathname, routeData]) } else { staticRoutes.set(pathname, routeData) diff --git a/src/api/routeplanner.ts b/src/api/routeplanner.ts index 69583d5f..95a1694e 100644 --- a/src/api/routeplanner.ts +++ b/src/api/routeplanner.ts @@ -407,7 +407,12 @@ function handler( */ const routePlannerRoute: ApiRouteModule = { handler, - methods: ['GET', 'POST'] + methods: ['GET', 'POST'], + paths: [ + '/v4/routeplanner/status', + '/v4/routeplanner/free/address', + '/v4/routeplanner/free/all' + ] } export default routePlannerRoute diff --git a/src/typings/api/api.types.ts b/src/typings/api/api.types.ts index 230683e4..61c94585 100644 --- a/src/typings/api/api.types.ts +++ b/src/typings/api/api.types.ts @@ -196,6 +196,11 @@ export interface ApiRouteModule { */ handler: ApiRouteHandler + /** + * Static pathnames this module handles, overriding the filename-derived pathname. + */ + paths?: string[] + /** * Allowed HTTP methods (defaults to GET). */