-
-
Notifications
You must be signed in to change notification settings - Fork 753
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
Is it possible to handle nested routes in feather? #97
Comments
There is the feathers-associations plugin. Even though it is not fully finished yet it is already possible to do things like: // Both associations should only work if there is a /users service registered already
app.use('/users', userService)
.use('/items', itemService);
// Pass service name in an array
// Calls itemService.findAll({ userId: <userId> })
app.associate('/users/:userId/items', ['items']); So you can do Which will retrieve all items with This does however not allow something like You can however easily implement your own middleware to e.g. retrieve the user items by their index for this route like so: app.get('/users/:userId/items/:itemIndex', function(req, res) {
var itemService = app.service('items');
var userId = req.params.userId;
var itemIndex = req.params.itemIndex;
itemService.find({ query: {
userId: userId
}
}, function(error, items) {
res.json(items[itemindex]);
});
}); |
Closing this issue as my previous comment hopefully solves it. |
Ya this works but we might need to look at how we handle deeply nested routes. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs. |
Hello,
I am wondering whether it is possible to handle nested routes using feather. For example:
GET /user
GET /user/5
GET /user/5/items
GET /user/5/items/6
If yes, can you please provide sample code? Appreciate it!
The text was updated successfully, but these errors were encountered: