2.0.1 • Published 6 years ago

koa-rest-controller v2.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

koa-rest-controller build

koa-rest-controller is a super simple tool to build Koa.js controller like Laravel controller

Requirement

  • node.js >= 8

Install

yarn add koa-rest-controller

Usage

Basically, you can assign an object to get koa-router routes

const rest = require('koa-rest-controller')

const controller = {
  index (ctx) {

  },
  store (ctx) {

  },
  // ...
}

rest(
  {
    resource: 'foo',
    controller
  }
)

Or, you can assign nested resource like this

rest(
  {
    resource: ['foo', 'bar'],
    controller
  }
)

The path looks like this /foo/:fooId/bar/:id

keydescriptiontype
resourceRoute resources, it should be an array or a string.string or array
controllerAn object to define CRUD like Laravel project.object
routeMiddlewareAn object to define CRUD middleware like Laravel project.object
prefixAdd prefix to all routesstring
middlewareAdd koa middleware to all routesfunction
2.0.1

6 years ago

2.0.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago