Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ async function loadRoutes(): Promise<ApiRouteCollection> {
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)
Expand Down
7 changes: 6 additions & 1 deletion src/api/routeplanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions src/typings/api/api.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
*/
Expand Down
Loading