2.2.1 • Published 3 years ago

koa-joi-rest v2.2.1

Weekly downloads
14
License
MIT
Repository
github
Last release
3 years ago

koa-joi-rest build

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

Requirement

  • node.js >= 8

Install

npm install --save koa-joi-rest

Usage

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

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

const handlers = {
  index (ctx) {

  },
  store (ctx) {

  },
  // ...
}

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

Or, you can assign nested resource like this

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

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

keydescriptiontype
resourceRoute resources, it should be an array or a string.string or array
handlersAn object to define CRUD like Laravel project.object
middlewaresAn object to define CRUD middleware like Laravel project.object
validatesvalidation object provided by joi-router.object
prefixAdd prefix to all routesstring
middlewareAdd koa middleware to all routesfunction
0.0.1

2 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.4

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.0

5 years ago