New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@zenweb/controller

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zenweb/controller

Zenweb Controller module

npmnpm
Version
3.1.0
Version published
Weekly downloads
651
123.71%
Maintainers
1
Weekly downloads
 
Created
Source

zenweb controller

可以像 spring 一样通过注解注入使用控制器

function actionLog(ctx: Context, next: Next) {
  console.log('actionLog middleware')
  return next();
}

function loginRequired(ctx: Context, next: Next) {
  console.log('loginRequired middleware')
  return next();
}

// 控制器全局中间件
@controller(actionLog)
export class Simpe {
  // 自动注入
  @inject
  ctx: Context;

  @init // 控制器每次被请求时候都会执行
  init() {
    console.log('init');
  }

  // 映射一个路径, 不指定参数默认为 `GET /方法名`
  @mapping()
  simple(ctx: Context) { // 也可以通过方法的参数自动注入
    ctx.body = 'simple';
  }

  // 每个方法都可以自定义中间件
  @mapping('GET', '/aaa', loginRequired)
  aaa() {
    this.ctx.body = 'aaa';
  }
}

Keywords

web

FAQs

Package last updated on 15 Apr 2022

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