koa-easy-go
v1.0.10
Published
A web framework is base on koa for coding easy
Downloads
3
Maintainers
Readme
koa easy go
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