-
Notifications
You must be signed in to change notification settings - Fork 19
Service Addon
Use the ember-jsonapi-resources addon to create a data "service" Addon for your Ember applications.
Many Ember apps use the same API and same endpoints. Each application could install an Ember CLI Addon as a data service module for a specific API endpoint (resource).
- Generate an Addon
- Uninstall Ember Data
- Install the
ember-jsonapi-resources
addon - Generate a
jsonapi-resource
- Generate a
blueprint
- Update your package.json with description and version.
Below is a summary of the commands to setup a data service addon using ember-jsonapi-resources…
ember addon hotels-service
npm rm ember-data --save-dev
ember install ember-jsonapi-resources
ember g jsonapi-resource hotel name:string reservation-date:date duration:number created-at:date updated-at:date
ember generate jsonapi-blueprint hotels-service
Use npm link
for local development using your data service.
In your package.json use a github URL to reference the dependency
:
"dependencies": {
"hotels-service": "git+ssh://[email protected]:organization/hotels-service.git#0.1.0"
}
If you do not wish to publish your NPM module, in your package.json file… set private
to true
and license
to "UNLICENSED"
.
There is no requirement to using services for each of your API endpoints. This is an advantage only when you have many apps or perhaps engines.
An alternative to a stand-alone addon is to use an "In-Repo Addon"; example of generating an in-repo addon below…
ember install ember-jsonapi-resources
ember generate in-repo-addon hotels-service
ember generate jsonapi-resource hotel name:string reservation-date:date duration:number created-at:date updated-at:date --in-repo-addon hotels-service