Skip to content
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

routes as root-routes and nested-routes #470

Open
regnerisch opened this issue Jul 26, 2018 · 0 comments
Open

routes as root-routes and nested-routes #470

regnerisch opened this issue Jul 26, 2018 · 0 comments

Comments

@regnerisch
Copy link

regnerisch commented Jul 26, 2018

node.js version: 10.7.0

npm/yarn and version: npm 6.1.0

koa-router version: 7.4.0

koa version: 2.5.2

Code sample:

// --- Issues
const issueRouter = new Router({'prefix': '/issues'});

issueRouter.get('/', IssuesController.index);

// --- Projects
const projectRouter = new Router({'prefix': '/projects'});

projectRouter.get('/', ProjectsController.index);
projectRouter.get('/:id', ProjectsController.view);

projectRouter.use('/:id', issueRouter.routes());

// --- Router
const router = new Router();

router
    .use(projectRouter.routes())
    .use(issueRouter.routes());

export default router.routes();

Is it possible to get issueRouter routes as root-routes and nested-routes? Currently it seems not to be possible.
I want to use it as: /issues/PROJECT_ID+ISSUE_ID or over the project /projects/PROJECT_ID/issues/ISSUE_ID
Is this somehow possible if yes - how - if not maybe you can add support for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant