diff --git a/striker-ui-api/src/lib/rrouters.ts b/striker-ui-api/src/lib/rrouters.ts index deb76955..619b1bb3 100644 --- a/striker-ui-api/src/lib/rrouters.ts +++ b/striker-ui-api/src/lib/rrouters.ts @@ -10,13 +10,21 @@ export const rrouters = < >( app: A, union: Readonly | R, - { key, route = '/' }: { key?: string; route?: string } = {}, + { + assign = (router) => [router], + key, + route = '/', + }: { + assign?: (router: R) => R[]; + key?: keyof M; + route?: string; + } = {}, ) => { if ('route' in union) { stdout(`Setting up route ${route}`); - app.use(route, union as R); + app.use(route, ...assign(union as R)); } else if (key) { - rrouters(app, union[key], { route: path.posix.join(route, key) }); + rrouters(app, union[key], { route: path.posix.join(route, String(key)) }); } else { Object.entries(union).forEach(([extend, subunion]) => { rrouters(app, subunion, { route: path.posix.join(route, extend) });