You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
app.configure(feathers.rest(functionrestFormatter(req,res){res.format({'text/plain': function(){res.end('The todo is: '+res.data.description);},'application/json': function(){res.json(res.data);}});}));
I don't think you can use file name extensions this way but setting the Accept HTTP header should be possible with every client.
Or create a separate app and use it on a different route (as done with the new Testee):
Very clever Dave 😉. Totally didn't think of that one.
As for content negotiation say I want to render out a specific template. For example I hit the /users endpoint and I want to render out the 'users' template for html. When I tried that I actually didn't have access to the request object and therefore wasn't able to determine the path.
Yep that works pretty well and what I had tried. For some reason my req.path is not right so I need to grab req.route.path.
Regardless, the solution is good but it gets complicated when you have urls like /users/:id and you want to res.render('user', {data: res.data}). Possibly namespacing your feathers routes and declaring your own html route handlers might be the best solution for separating JSON/XML routes from HTML ones.
Otherwise you end up writing some janky logic to determine which template should be rendered based on the route path. This could get really complicated if you have stuff like /users/:id/subscriptions, as an example.
I don't think so. Every Express application has its individual middleware stack. The easiest way is probably to put common middleware into a separate setup function and .configure it on each application:
I think we can close this issue? If there is still things to think about I'd put them in a new one. I worked with a Feathers app that had some static pages and didn't run into any hard problems connecting services and rendering static pages.
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.
Activity
daffl commentedon Sep 2, 2014
I'm not sure the prefix is necessary. Why couldn't you just do
Or create a separate app and use it on a different route (as done with the new Testee):
As for the content type, Express does allow REST content negotiation, for Feathers like:
I don't think you can use file name extensions this way but setting the
AcceptHTTP header should be possible with every client.ekryski commentedon Sep 2, 2014
Very clever Dave 😉. Totally didn't think of that one.
As for content negotiation say I want to render out a specific template. For example I hit the
/usersendpoint and I want to render out the 'users' template for html. When I tried that I actually didn't have access to the request object and therefore wasn't able to determine the path.daffl commentedon Sep 2, 2014
I would keep that separate from the service though. In the negotiator it would be
The view information could also be added with a custom middleware:
ekryski commentedon Sep 2, 2014
Yep that works pretty well and what I had tried. For some reason my
req.pathis not right so I need to grabreq.route.path.Regardless, the solution is good but it gets complicated when you have urls like
/users/:idand you want tores.render('user', {data: res.data}). Possibly namespacing your feathers routes and declaring your own html route handlers might be the best solution for separating JSON/XML routes from HTML ones.Otherwise you end up writing some janky logic to determine which template should be rendered based on the route path. This could get really complicated if you have stuff like
/users/:id/subscriptions, as an example.agonbina commentedon Oct 9, 2014
@daffl In the case where you have
do configurations from
appapply to theapiinstance too?Ex. if I have
, do we still need to do the same for
apior since we have applied those configs before 'mounting'apithey would apply to it as well?Thanks!
daffl commentedon Oct 9, 2014
I don't think so. Every Express application has its individual middleware stack. The easiest way is probably to put common middleware into a separate
setupfunction and.configureit on each application:agonbina commentedon Oct 9, 2014
Yep, just tried leaving out configuration for the
apiand it no longer works as expected, so definitely each instance has its own middleware stack.Thanks for the quick response!
daffl commentedon Dec 16, 2014
I think we can close this issue? If there is still things to think about I'd put them in a new one. I worked with a Feathers app that had some static pages and didn't run into any hard problems connecting services and rendering static pages.
Update to Buzzard infrastructure (#93)
Update to Buzzard infrastructure (#93)
fix(package): update generator-feathers to version 1.1.0 (#93)
lock commentedon Feb 8, 2019
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.