hapi-harvester
v0.5.1
Published
Harvester Hapi Plugin
Downloads
28
Readme
hapi-harvester
a JSONAPI 1.0 plugin for Hapi
Overview
Harvester is a Hapi plugin which enables you to define JSONAPI 1.0 resources in an easy, boilerplate-free manner.
// bootstrap a hapi server... and register the plugin
server.register(
[{
register: harvester,
options: {
adapter: adapter({
mongodbUrl: 'mongodb://localhost/test',
oplogConnectionString: 'mongodb://localhost/local'})
}
}], () => {
// define a jsonapi schema
var brands = {
type: 'brands',
attributes: {
// use Joi to set validation constraints
code: Joi.string(),
description: Joi.string()
}
}
const hh = server.plugins['hapi-harvester']
// register the routes
hh.routes.all(brands).forEach((route) => {
server.route(route)
})
server.start()
})
The code for a more complete server can be found in the /example folder.
Features
JSON-API 1.0
- CRUD
- Filtering
- Sorting
- Pagination
- Resource Relationships
- Inclusion of Linked Resources
- Sparse fieldsets
- Errors
Other
- Extended filter operators : lt, gt, lte, gte
- Publish change events through SSE