• Stars
    star
    488
  • Rank 90,182 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A config driven NodeJS framework implementing json:api and GraphQL

Build Status Coverage Status npm version Dependencies Status

jsonapi-server

Greenkeeper badge

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

jsonApi.setConfig({
  port: 16006,
  graphiql: true
});

jsonApi.define({
  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)
  }
});

jsonApi.start();

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:

http://localhost:16006/rest/photos

or, for GraphQL:

http://localhost:16006/rest/

the example implementation can be found here

More Repositories

1

hxTracer

A dependency-free Javascript Tracer
JavaScript
378
star
2

culture

Coding culture for HX
92
star
3

jsonapi-client

Easily consume a json:api service in Javascript.
JavaScript
68
star
4

esq

Simple query builder for elasticsearch
JavaScript
56
star
5

jsonapi-store-relationaldb

A relational database handler for jsonapi-server
JavaScript
33
star
6

wsdl2.js

A NodeJS tool to consume a WSDL file and output a neat, manageable Javascript library.
JavaScript
25
star
7

node-librato-metrics

JavaScript
21
star
8

chrome-extension-starter

Basic types of chrome extension, examples and reading materials
JavaScript
16
star
9

jsonapi-store-mongodb

A mongodb database handler for jsonapi-server
JavaScript
15
star
10

ui-toolkit

DEPRECATED - CSS & React components
JavaScript
14
star
11

flex-less

Flexbox LESS Mixin
CSS
14
star
12

jsonapi-store-elasticsearch

An elasticsearch database handler for jsonapi-server
JavaScript
10
star
13

iinChecker

Issuer identification number checker which returns details about a credit/debit card
JavaScript
8
star
14

mocha-performance

Runtime performance analysis off the back of a mocha test suite.
JavaScript
7
star
15

node-zabbix-sender

Its a node - zabbix - sender
JavaScript
6
star
16

cluster-manager

package to manage apps that want to use nodejs cluster module.
JavaScript
6
star
17

node-cookie-derail

Decode, and optionally verify the signature of, unencrypted Ruby on Rails cookies.
JavaScript
6
star
18

react-data-attributes-mixin

Take data from props and convert it to HTML data-* attributes
JavaScript
6
star
19

barometer

Framework agnostic browser performance metrics
JavaScript
5
star
20

truman

Simple test fixtures for single page apps
JavaScript
4
star
21

featherLog

Control what you log - Feather, a lightweight logging facility for node.js
JavaScript
4
star
22

praetorian

Structured JSON validator
JavaScript
4
star
23

deployment-helpers

A collection of scripts that can be used as part of a deployment process.
JavaScript
4
star
24

make-up

All of the checks for all of the linters.
JavaScript
3
star
25

holidayextras.github.com

HX Tech Team Blog
HTML
3
star
26

WorkerJS

Making concurrent Javascript easier
JavaScript
3
star
27

redis_mon

A lightweight redis monitor script
JavaScript
2
star
28

hxMetrics

instrument NodeJS modules without touching their source code
JavaScript
2
star
29

react-time-select

React Bootstrap select box populated with a configurable and localizable time range
JavaScript
2
star
30

varnish-bits

Couple of scripts etc we use for varnish
Shell
2
star
31

node-pester

Will pester you, if you're running the wrong version of Node.js for your app
JavaScript
2
star
32

plugin-jsonapi

A hapijs plugin for a jsonapi style output to all requests.
JavaScript
2
star
33

static-site-generator

An open source plugin that brings together a content API together with metalsmith in order to generate static sites.
JavaScript
1
star
34

node-queuemetrics

Interface into Queuemetrics' API
JavaScript
1
star
35

partner-api-docs

Holiday Extras Partner API Docs.
JavaScript
1
star
36

recruitment-tasks

technical tasks for HX Engineer applications
1
star
37

snyk-report

Assists in generating human readable snyk reports for CI integration
JavaScript
1
star
38

react-component-template

A starter template for a React component. Clone this code and push up under a different repo to build your own components.
JavaScript
1
star
39

react-date-time-group

Datepicker + time selection component
JavaScript
1
star
40

partner-api-examples

Worked examples in different languages of how to integrate with Holiday Extras Partner API
1
star
41

bigjson

Python
1
star
42

example-js-project

An example codebase demonstrating our preferred project and build process setup
JavaScript
1
star
43

mocha-exports-to-describe

Converts mocha exports tests to use the describe syntax
JavaScript
1
star