Koapi
RESTful API framework based on koa and bookshelf
Writing a RESTful API has never been so easy!
Intro
Koapi is a library for building RESTful APIs in a really simple way.
Installation
npm install koapi
Write your APIs in just ONE minute
Assume you have database below
posts
Table id | title | contents | created_at | updated_at |
---|---|---|---|---|
1 | Title | Contents | 2016-8-1 | 2016-8-1 |
comments
Table id | post_id | title | contents | created_at | updated_at |
---|---|---|---|---|---|
1 | 1 | Title | Comment | 2016-8-1 | 2016-8-1 |
Here we go!
app.js
const Koapi router middlewares model = const app = ; /****************** Connect to database ******************/model Base { return 'comments' } { return true }Base { return 'posts' } { return true } { return this; } /****************** Implement Routers ******************/ const comments = router // POST /posts// GET /posts// GET /posts/:id// PATCH /posts/:id// DELETE /posts/:idconst posts = router /****************** Run server ******************/appapp app;
run
node ./app
You have done your RESTful APIs in ONE minute
Your API is far more complicated than this?
Checkout Koapp for your situation.