A config driven NodeJS framework implementing json:api
Last updated 2 years ago by championswimmer .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @coding-blocks/jsonapi-server 
SYNC missed versions from official npm registry.

Build Status Coverage Status npm version Dependencies Status


Greenkeeper badge

About this Fork

NOTE: This is a fork of holidayextra's jsonapi-server We have merged a lot of pending PRs on the original repo that we felt we would gain advantage from. The original project was coing a bit too slowly for our needs.

Differences from upstream

primaryKey is configurable

In upstream, keys are by default uuid and are taken from DB, if generateId = true We instead use a different property primaryKey, whose possible values are

  • uuid : Uses UUID v4 (generated from the client)
  • autoincrement : Uses AUTOINCREMENT integers

*In future there might be other types of primaryKeys if required.

relationship key type is configurable

When creating a field, you can state how to relate it

  attributes: {
    author: jsonApi.Joi.one('people').uidType('uuid')

You'd want to use our version of jsonapi-store-[*] plugins with this as the original versions will not be compatible with this

The rest of the readme is verbatim copy of the original project


A config driven NodeJS framework implementing json:api and GraphQL. You define the resources, it provides the api.

Motivation / Justification / Rationale

This framework solves the challenges of json:api and GraphQL without coupling us to any one ORM solution. Every other module out there is either tightly coupled to a database implementation, tracking an old version of the json:api spec, or is merely a helper library for a small feature. If you're building an API and your use case only involves reading and writing to a data store... well count yourself lucky. For everyone else, this framework provides the flexibility to provide a complex API without being confined to any one technology.

A config driven approach to building an API enables:

  • Enforced json:api responses
  • Automatic GraphQL schema generation
  • Request validation
  • Payload validation
  • Automatic documentation generation
  • Automatic inclusions
  • Automatic routing
  • Automatic handling of relationships

Ultimately, the only things you as a user of this framework need to care about are:

  • What are my resources called
  • What properties do my resources have
  • For each resource, implement a handler for:
    • createing a resource
    • deleteing a resource
    • searching for many resources
    • finding a specific resource
    • updateing a specific resource

We've created handlers to automatically map our config over to database solutions help people get off the ground:

We've also written a library to ease the consumption of a json:api compliant service, if GraphQL isn't your thing:

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");

  port: 16006,
  graphiql: true

  resource: "photos",
  handlers: new jsonApi.MemoryHandler(),
  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)


Your new API will be alive at http://localhost:16006/ and your photos resources will be at http://localhost:16006/photos. The GraphiQL interface will be available at http://localhost:16006/.

Show me a 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 the JSON:API endpoints:


or, for GraphQL:


the example implementation can be found here

Current Tags

  • 5.4.4                                ...           latest (2 years ago)

19 Versions

  • 5.4.4                                ...           2 years ago
  • 5.4.3                                ...           2 years ago
  • 5.4.2                                ...           2 years ago
  • 5.4.1                                ...           2 years ago
  • 5.4.0                                ...           2 years ago
  • 5.2.1                                ...           2 years ago
  • 5.2.0                                ...           2 years ago
  • 5.1.2                                ...           2 years ago
  • 5.1.1                                ...           2 years ago
  • 5.1.0                                ...           3 years ago
  • 5.0.0                                ...           3 years ago
  • 4.1.1                                ...           3 years ago
  • 4.1.0                                ...           3 years ago
  • 4.0.0                                ...           3 years ago
  • 3.3.0                                ...           3 years ago
  • 3.2.6                                ...           3 years ago
  • 3.2.5                                ...           3 years ago
  • 3.2.4                                ...           3 years ago
  • 3.2.3                                ...           3 years ago
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 20
Dependencies (18)
Dev Dependencies (15)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |