stefanpenner/ember-cli — pull request #1058 by manuelmitasch (2014-06-17 22:23:23+00:00)
Title: Adds rest-api blueprint - WIP

This adds a new blueprint called `rest-api`. It generates node routes for a given model name that work out-of-the-box with the `DS.RESTAdapter` + `DS.RESTSerializer`.

* Usage: eg. `ember generate rest-api post` to generate a REST route for a `post` model
* Uses NeDB as a very lightweight db with a nice API.
* Includes a serializer to serialize/normalize from NeDB (primaryKey: _id) to `DS.RESTSerializer` (primaryKey: id)
* Uses a node shim package of the ember-inflector to pluralize the modelname. (Need to publish that to npm, if that's good for you guys)
* It adds an application adapter to namespace api requests. This is needed in order to minimize collisions between ember routes and rest api routes.

There are some things that I'm not totally happy:

1. As it uses two node packages (nedb + ember-inflector-node-shim) I have added the packages to `blueprint/app/files/package.json`. This means that every ember-cli user has to install these dependencies, even thought he might not use the `rest-api` blueprint.

2. The api-stub and rest-api blueprint now contain the same file in `files/server/index.js`. If they diverge, using both will have the side-effect. It would try to override the file on every `ember generate api-stub` or `ember generate rest-api` call.

3. NeDB is used as a in-memory database ATM. Thus, the data is lost when the server is restarted. It is not lost when the watcher initiates a new build. We could easily add a filename when creating the Datastore and changes will be persisted permanently: `db = new Datastore({ filename: 'path/to/datafile' })`. I'm not sure which of the two options should be the default. Any thoughts?

PR for issue: #920
ping @rjackson: as offered in the issue, please review.