/jsonapi-server

A fully featured NodeJS server implementation of json:api

Primary LanguageJavaScriptMIT LicenseMIT

Coverage Status Build Status npm version Code Climate Dependencies Status

jsonapi-server

jsonapi-server is a fully featured NodeJS server implementation of json:api. You provide the resources, we provide the api.

Full documentation

The tl;dr

You can have a complete json:api server providing a photos resource with just this:

var jsonApi = require("jsonapi-server");

jsonApi.setConfig({
  base: "rest",
  port: 16006,
});

jsonApi.define({
  resource: "photos",
  handlers: jsonApi.mockHandlers,
  attributes: {
    title: jsonApi.Joi.string()
    url: jsonApi.Joi.string().uri()
    height: jsonApi.Joi.number().min(1).max(10000).precision(0)
    width: jsonApi.Joi.number().min(1).max(10000).precision(0)
  }
});

jsonApi.start();

Your new API will be alive at http://localhost:16006/rest/ and your photos resources will be at http://localhost:16006/rest/photos.

Show me an full example!

Fire up an example json:api server using the resources mentioned in the official spec via:

git clone https://github.com/holidayextras/jsonapi-server.git
npm install
npm start

then browse to

http://localhost:16006/rest/photos

the example implementation can be found here