1.0.10 • Published 7 years ago

koa-easy-go v1.0.10

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

koa easy go

Build Status

This project is base on Koa and Koa-route. I add some decorators into this project for coding easy. It seems like Asp.net MVC, but it's not that. Those decorators are in src/decorators directory.

Codes for creating controller and actions:

// src/controllers/v1/exampleController.js
import { action, controller, method } from 'koa-easy-go';

@controller('example')
class ExampleV1Controller {

    @action('say')
    @method('post')
    async ActionSay(ctx) {
        ctx.body = { result: 'say' };
    }

    @action('hello')
    async ActionHello(ctx) {
        ctx.body = { result: 'hello' };
    }
}

export default ExampleV1Controller;

These actions are middlewares of koa. We can use actions to do all the things, just like using koa middlewares.

Then, register them to koa instance

// src/controllers/router.js
import exampleV1 from './v1/exampleController';

export default (app) => exampleV1(app);

Finally, run it

// src/app.js
import { createApp } from 'koa-easy-go';
import router from './controllers/router';

export default createApp(null, router).listen(3000);

More information are in Wiki Document

Example

Backend-Mailbox48

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago