JedWatson/keystone — pull request #404 by davidbanham (2014-06-04 11:10:39+00:00)
Title: Restish

I think this is now at the point where it warrants discussion. The point of this PR is to get an out-of-the-box generic list API from Keystone that works with [AngularJS' resource service](https://docs.angularjs.org/api/ngResource/service/$resource) and is generally rest-y.

The main things I've done are:

1. add a new getAll method to the generic list api
1. add a new endpoint at /keystone/restish_api

The new getAll method does what it says on the tin. Returns all members of a list. The obvious threat here is that maybe that list is gigantic. If so, I think the onus is on the app developer to add their own API routes. I think the happy path is to have it Just Work out of the box, and once you've got enough data for that to be a problem you can deal with it in whatever way makes sense for your app.

It would have been super-nice to be able to overload the /keystone/api endpoint so that it was compatible with angular, but I couldn't see a way to do it without also intercepting the old-style API calls to that endpoint. In order to not break backwards compatibility, I've namespaced these changes.

I think it's worth asking the question about backwards compatibility with this API, though. To my mind, the closer we get to the common conception of RESTfulness, the better. Even if you're not using Angular, this should work with most things that expect a rails-style REST API. Anyone that's used that kind of API in the past should be able to get up to speed pretty quickly without needing to read the docs.