Nested Public Modules

    koa-routed

    1.0.4 • Public • Published

    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

    Install

    npm i koa-routed

    DownloadsWeekly Downloads

    0

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    2.25 kB

    Total Files

    5

    Last publish

    Collaborators

    • cooperhsiung