New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

circe-controller

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

circe-controller

## 安装

0.0.3
latest
Source
npm
Version published
Maintainers
1
Created
Source

circe-controller 装饰器形式路由配置

安装

NPM

使用

import * as Koa from 'koa'
import {IContext, Controller, Get, Post, Put, Delete, Use, toRouter} from 'circe-controller'

@Controller('/users')
@Use(someMiddleware)
class UserController {

  @Get()
  @Use(otherMiddleware)
  async list (ctx: IContext) {}

  @Get()
  async get (ctx: IContext) {}

  @Post()
  async create (ctx: IContext) {}

  @Put()
  async update (ctx: IContext) {}

  @Delete()
  async delete (ctx: IContext) {}
}

const app = new Koa()
const router = toRouter([UserController])

app.use(router.routes())
app.use(router.allowedMethods())

API

function toRouter (controllers: Controller[]): Router

已支持装饰器

  • Controller
  • Use
  • Action
  • Get
  • Post
  • Put
  • Patch
  • Delete
  • Head
  • Options
  • All

FAQs

Package last updated on 07 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts