ES6 Component that works as an omnirouter middleware to provide jsonapi responses.
npm install jsonapi-formatterES6 Component that works as an omnirouter middleware to provide jsonapi responses.
``javascript
import JsonApiFormatter from "jsonapi-formatter";
import Router from "omnirouter";
router = new Router(options);
router.get("/user", (request, response) => {
response.internalServerError(new Error("Oh no!"));
});
//inject middleware
router.use(JsonApiFormatter);
router.listen(portNumber, () => {
//now your responses will return an envelope according to the jsonapi format (notice that the entities you may return inside of it are not automatically converted, currently)
}));
`
    
Every build and release is automatically tested on the following platforms:
!node 0.12.x !node 0.11.x !node 0.10.x
!iojs 2.x.x !iojs 1.x.x
If your platform is not listed above, you can test your local environment for compatibility by copying and pasting the following commands into your terminal:
``
npm install jsonapi-formatter
cd node_modules/jsonapi-formatter
gulp test-local
Copy and paste the following command into your terminal to install Jsonapi-formatter:
``
npm install jsonapi-formatter --save
``
// ES6
import jsonapi-formatter from "jsonapi-formatter";
``
// ES5
var jsonapi-formatter = require("jsonapi-formatter");
``
// Require.js
define(["require"] , function (require) {
var jsonapi-formatter = require("jsonapi-formatter");
});
`javascript
import JsonApiFormatter from "jsonapi-formatter";
import Router from "omnirouter";
router = new Router(options);
router.get("/user", (request, response) => {
response.internalServerError(new Error("Oh no!"));
});
//inject middleware
router.use(JsonApiFormatter);
router.listen(portNumber, () => {
//now your responses will return an envelope according to the jsonapi format (notice that the entities you may return inside of it are not automatically converted, currently)
}));
`
See something that could use improvement? Have a great feature idea? We listen!
You can submit your ideas through our issues system, or make the modifications yourself and submit them to us in the form of a GitHub pull request.
We always aim to be friendly and helpful.
It's easy to run the test suite locally, and highly recommended if you're using Jsonapi-formatter.js on a platform we aren't automatically testing for.
```
npm test