egg-router-decorator2
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

egg-router-decorator2

Introduction

use decorator declare making eggjs router easy.

Usage

// home.ts
import { Controller } from 'egg';
import { GET } from 'egg-router-decorator2';

class HomeController extends Controller {
  @GET('/')
  async heartbeat(): Promise<any> {
    this.ctx.body = 'hello world';
  }
}

export default HomeController;

// router.ts
import { initRouter } from 'egg-router-decorator2';

export default (app) => {
  initRouter(app, { prefix: '/api' });
};

API

  • GET(path,...middlewares)

  • POST(path,...middlewares)

  • PUT(path,...middlewares)

  • DELETE(path,...middlewares)

  • PATCH(path,...middlewares)

  • OPTIONS(path,...middlewares)

  • HEAD(path,...middlewares)

  • Request(method,path,...middlewares)

    path <string>, required

    method: <string> ,'GET','PUT','POST','DELETE','PATCH','OPTIONS','HEAD',

    middlewares: <Array[string]> , names of eggjs middlewares

  • initRouter(app: Application,options={prefix:''})

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.40latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.40
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i egg-router-decorator2

Weekly Downloads

0

Version

0.0.4

License

MIT

Unpacked Size

12.5 kB

Total Files

9

Last publish

Collaborators

  • jerryshan2011