-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defining routes as both nested and top level #74
Comments
well, in this case, I'd recommend using regex to match both paths, since I think that the only way we can do it since Nestjs is already supporting path regex:
See it in action here: https://regex101.com/r/R7IxYM/2
|
I ran into a similar issue and I got around it by doing a bit more leg work. What you could do for the time being is create a new Module called BoardStoryModule and extend your story module, then import the BoardStoryModule into your routing document and use it. |
We have a similar issue, with dynamic modules. When trying to setup the router on two different modules utilising the same shared module dynamically initialised. Setup as follows: const AnimalModuleInstance1: DynamicModule = {
module: SharedModuleWithRoutes,
};
const AnimalModuleInstance2: DynamicModule = {
module: SharedModuleWithRoutes,
};
const DOG_ROUTES: Routes = [
{
path: '/1/',
module: DogModule,
children: [
AnimalModuleInstance1.module,
]
}
];
const CAT_ROUTES: Routes = [
{
path: '/2/',
module: CatModule,
children: [
AnimalModuleInstance2.module,
]
}
]; We run into issues as the router module tries to reference the module based on the nest-router/src/router.module.ts Line 20 in f7b2374
setting the base path to either changing the reflector to use the module object reference rather than the metatype seems to resolve our issue - however will not work if string based module references are allowed in - const modulePath: string = Reflect.getMetadata(MODULE_PATH, nestModule.metatype);
+ const modulePath: string = Reflect.getMetadata(MODULE_PATH, nestModule); |
In my application I have an entity 'stories', that I want to be able to reach from the top level of routes (e.g.
api/v1/stories
) but also to access it nested so that it can have parameters for another entity, e.g.api/v1/boards/:boardId/stories
.Is this possible with the current build? I've tried out different ways of organising them but it seems that multiple declarations of a module will overwrite any previous ones.
For example one setup that I tried was:
In this case the boards route and nested stories route works, but the top level stories route does not. If i place the top level stories route after the nested route, that one works and the nested one doesn't.
The text was updated successfully, but these errors were encountered: