Patch Maker
Rapidly build HTTP PATCH endpoints for you mongo-backed restful resources.
Getting Started
Install Patch Maker:
npm install patch-maker --save
Overview
Patch Maker is a PATCH submission parser builder/dsl. It allows you to quickly and concisely describe a mutable mongo-backed restful resource.
Examples
Build a Parser (with the help of the 'accurized' module):
require 'accurize' require 'patch-maker'apppatch '/types' parser = patchparser -> @prop 'types'-> @oper 'set' return fail 'Types must be a list of strings.' unless is_array types return fail 'Types cannot be empty.' if is_empty types for type in types return fail 'Each type must be a string' unless is_string type return fail 'A type cannot be empty.' if is_empty type Typereqfindname: $in: typesall return fail 'Unrecognized type(s) specified.' unless typeslength is actuallength pass types @oper 'add' for type in types return fail 'A type cannot be empty.' if is_empty type Typereqfindname: $in: typesall return fail 'Unrecognized type(s) specified.' unless typeslength is actuallength pass types @oper 'rem' if is_empty differencegranttypestypes return fail 'The update must leave the grant with at least one type.' pass types updatesparse reqbody Grantreqfind_and_modify _id: id_forgrant'_id''asc'updatesnew: true resjson Grantgrant_forgrantres resjson 400 errors
Parse a Patch:
= require 'patch-maker'parser =
Contributing
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.
Release History
(Nothing yet)