hapi-crud-promise
Basics
Reduce repetitive route setup for basic CRUD apps.
Provide one route and a 5 handlers:
/api/things/{thingId}
And get 5 routes added to your server:
GET /api/things
POST /api/things
GET /api/things/{thingId}
PUT /api/things/{thingId}
DELETE /api/things/{thingId}
Simple Usage
const Hapi = require('hapi');
const Joi = require('joi');
const hapiCrudPromise = require('../index');
const server = new Hapi.Server();
server.connection({ host: '127.0.0.1' });
hapiCrudPromise(server, {
path: '/api/things/{thingId}',
config: {
validate: {
query: {
limit: Joi.number().optional()
}
params: {
thingId: Joi.string().required()
},
payload: Joi.object({
name: Joi.string().required()
})
}
},
crudRead(req) {
return
},
crudReadAll(req) {
return
},
crudUpdate(req) {
return
},
crudCreate(req) {
return
},
crudDelete(req) {
return
}
});
Contributing
Contributors wanted. If you are looking for a way to help out browse the Help Wanted issues and find one that looks good to you. If you have an idea to make hap-crud-promise better submit a pull request.
Pull Request Checklist
Checklist for submitting a pull request:
FAQ
Yeah, but with Promises! And active. And the Github repo is still live.
Can't I just create a bunch of routes manually?
CRUD routes are repetitive. Write less code and go outside.