4 ms·
OK, it looks like hooking this up with Angular directly is not going to work without pretty major changes. Angular's resource module is set up to work with "bro
by tehwebguy 13y ago
OK, it looks like hooking this up with Angular directly is not going to work without pretty major changes. Angular's resource module is set up to work with "broken" JSON APIs out of the box, presumably because most are set up that way.
Angular has way more to it so I'm probably going to leave it as is and continue hacking away at Fortune to make it a little more forgiving with the requests it handles.
I also exposed one more express method in /fortune.js:
Fortune.prototype.static = function() {
return express.static.apply(express, arguments);
};
Since Angular is all client side just creating a public folder was enough to serve up the required pages from the same app:
app.use(app.static(__dirname + '/public'));
- daliwali 13y agoAh, by the way, you shouldn't need to serve the front-end app from the same server as the API. By default, Fortune gives you CORS (Cross Origin Resource Sharing), so that clients from any domain can consume it. Also, Fortune should work out the box with Ember Data and my JSON API adapter: https://github.com/daliwali/ember-json-api https://github.com/daliwali/ember-json-api . Not to say that you should ditch Angular, but it will probably need quite a bit of modifications to its data layer to get it working with the JSON API spec. I will be working on a full, non-trivial example of what an Ember.js + Fortune.js application can be in the coming week(s). There is a current implementation that's in production at my company, but its unfortunately closed-source.