netiam
A pure REST library
This REST API library addresses some issues we had with API designs in our projects. It does not claim to provide a full featured solution and to be honest, it might never will. Nevertheless, someone might find this library useful. It works as connect middleware and you should be able to use it with any compatible infrastructure (e.g. express).
TOC
Get it
npm i -S netiam@7
Plugins
What can it do for you
- Authentication (with passportjs and OAuth 2.0)
- Authorization (with ACLs, inheritance support for roles, assertions and wildcards)
- Relationships(on resource level)
- Query language (effective and powerful filters with OData)
- Completely stateless (except cookie based sessions for authentication in browser apps)
- Support for the JSONAPI specification
- Auto response format detection
- Graph representation and rendering (as SVG)
- Extensible with plugins
Getting started
Creates a single route, using the data plugin to add some data and returns everything as JSON.
const app = const server = http app server
How it works
The core idea of this library is to have a stack of plugins executed in an asynchronous way.
const path = app
Plugin example
{ return { resbody = data; }}
Example
app
Error handling
You do not need to handle common API errors on your own. The library responds to the client at least with a proper HTTP status code (e.g. 404 for document not found) automatically.
Tests
Using mocha with should for tests and istanbul to check coverage.
npm test