json-patch-api
Provides an express middleware for a JSON store that supports real-time client updates using JSON-patch and mongojs as a backend for persistence.
Last updated 5 years ago by allain .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install json-patch-api 
SYNC missed versions from official npm registry.

json-patch-api

Provides an express middleware for a JSON store that supports real-time client updates using JSON-patch"

build status

Installation

This module is installed via npm:

$ npm install json-patch-api

Basic Usage

var jsonPatchApi = require('json-patch-api');

var app = express();
var io = require('socket.io')(server);

app.use('/api', require('json-patch-api')(io));

Middleware Routes

PUT /api/NAME

Stores whatever application/json payload you send it and replaces the current document and returns JSON-PATCH commands that are needed to update the document.

GET /api/NAME

Returns the current JSON document stored at the api endpoint. And a header X-Last-Patched with the epoch time at which the last patch was applied.

GET /api/NAME/patches?after=TIMESTAMP

Returns a JSON struct which represents a sequence of JSON-PATCH operations which, if repeated sequentially would yield the current state of the document given a snapshot from time TIMESTAMP.

POST /api/NAME/patches

With a JSON-Patch payload will apply the patch to the current endpoint's state and broadcast it to all listening clients.

Clients

See http://www.github.com/allain/json-patch-api-client)

Current Tags

  • 0.1.3                                ...           latest (5 years ago)

4 Versions

  • 0.1.3                                ...           5 years ago
  • 0.1.2                                ...           5 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (7)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |