1.1.0 • Published 7 years ago

koa-mr v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
7 years ago

koa-mr

koa extended with koa-route and koa-mount methods. So methods:

app.get(...)
app.post(...)
// methods available ['all', 'get', 'head', 'post', 'put', 'delete', 'connect', 'options', 'trace']

and

app.mount(...)

are already in place.

Usage example

index.js

const Koa = require('koa-mr')

const users = require('./users')
const home = require('./home')

const app = new Koa()

app.mount('/', home)
app.mount('/users', users)

app.listen(3000)
console.log('listen port 3000')

home.js

const Koa = require('koa-mr')
const app = new Koa()

app.get('/', function (ctx) {
  ctx.body = 'home'
})

module.exports = app

users.js

const Koa = require('koa-mr')
const app = new Koa()

app.get('/', function () {
  var users = [
    {id: 1, name: 'user1'},
    {id: 2, name: 'user2'},
    {id: 3, name: 'user3'}
  ]
  this.body = users
})

module.exports = app

Working example you can find here:

https://github.com/vladimirbuskin/koa-mr-example

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago