Web framework for prototyping hypermedia APIs.
Hello nerds. Fortune is a web framework for prototyping hypermedia APIs that implement the JSON API specification. It comes with a modular persistence layer, with adapters for NeDB (built-in), MongoDB, MySQL, Postgres, & SQLite.
Get it by installing from npm:
$ npm install fortune
There is a release tag for
v1.0 of JSON API, though Fortune does not yet implement the entire feature set. What needs to be done:
Fortune implements everything you need to get started with JSON API, with a few extra features:
It does not come with any authentication or authorization, you should implement your own application-specific logic (see keystore.js for an example).
The full guide and API documentation are located at fortunejs.com.
Here is a minimal application:
var fortune = require'fortune';var app = fortune;appresource'person'name: Stringage: Numberpets: 'pet' // "has many" relationship to pets;appresource'pet'name: Stringage: Numberowner: 'person' // "belongs to" relationship to a person;applisten1337;
This exposes a few routes for the
pet resources, as defined by the JSON API specification:
|GET||/people||/pets||Get a collection of resources, accepts query |
|POST||/people||/pets||Create a resource|
|GET||/people/||/pets/||Get a specific resource, or multiple: |
|PUT||/people/||/pets/||Create or update a resource|
|PATCH||/people/||/pets/||Patch a resource (see RFC 6902)|
|DELETE||/people/||/pets/||Delete a resource|
|GET||/people/||/pets/||Get a related resource (one level deep)|
Tests are written with Mocha, and are run against the built-in NeDB adapter, plus MongoDB & MySQL on Travis. You will also need to have the developer dependencies installed. To run tests:
$ npm test
For release history and roadmap, see CHANGELOG.md.
Fortune is licensed under the MIT license, see LICENSE.md.