Skip to content

Instantly share code, notes, and snippets.

@ozanmuyes
Last active February 13, 2019 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozanmuyes/78d7a09f738196ab5f8155c5c2cd1444 to your computer and use it in GitHub Desktop.
Save ozanmuyes/78d7a09f738196ab5f8155c5c2cd1444 to your computer and use it in GitHub Desktop.
posts.scope('Post', '/:postId', compose([postMiddleware1, postMiddleware2, (post) => {
// get the 'postId' via `ctx.params`
post.get('ViewPost', '/', PostsController.view);
post.scope('Comments', '/comments', compose([postCommentMiddleware1, postCommentMiddleware2, (comments) => {
comments.get('Index', '/', compose([postCommentIndexMW, CommentsController.index]));
// also get the 'commentId' via `ctx.params`
comments.get('View', '/:commentId', CommentsController.view);
}]));
}]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment