1.0.4 • Published 6 years ago

koa-routed v1.0.4

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

koa-routed

Route decorator for koa.

Installation

babel is required.

  • babel-preset-es2017
  • babel-plugin-transform-decorators-legacy

$ npm i koa-routed -S

Run

require('babel-register');
require('./app.js');

or

npm run build & npm start

Example

const routed = require('koa-routed');
const Koa = require('koa');
const app = new Koa();

const person = {

    @routed('/hello')
    sayHello(ctx, next) {
        ctx.body = 'Hello!'
    },

    @routed('/hi', {method:'post'})
    sayHi(ctx, next) {
        ctx.body = 'Hi!'
    }
};

app.use(person.sayHello);
app.use(person.sayHi);

app.listen(3000);
console.log('listening on port 3000');

License

MIT

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