you can make restful api router, easier with Barney
Decription
Cottage-Barney is a restful api router
made with therne/cottage. this router support middleware, HTTP status, URI param, and etc..
Get started
Installation
$ npm install --save cottage-barney
Example
const cottage = ;const Router = ; const app = ;const router = app; // this.params => URI params object like '/:id' // this.query => GET query object // this.req => koa.Request // this.req.body => Body object // this.res => koa.Response { // Do something! thisresstatus = RouterstatusOK; // We're support http status code's with 'david/http-status' return 'GET METHOD'; } { // Do something! return 'POST METHOD'; } { // Do something! return 'DELETE METHOD'; } router;router; // barney also support uri param app;
Middleware Usage
const cottage = ;const Router = ; const app = ;const router = app; const middleware = { // 1 argument is required routerres"status" = RouterstatusCREATED; // You can handling resposne, request, params, query}; router;router; /*Middleware can use with children.router.set('', {}, [ { path: '/', route: new Route(), middlewares: [ function(route) { // You can use middleware like this console.log("This is index!"); } ] }]); */ app;
Documentations
- API Documentation TBA
- Samples TBA