
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
@zenweb/controller
Advanced tools
在 src/controller 目录下新建一个文件 simple.ts
import { Context, mapping } from 'zenweb';
export class Controller {
@mapping()
index(ctx: Context) { // 如果函数名称为 index 则路径名称为 /,否则路径名称默认为函数名称
return 'Hello zenweb';
}
@mapping() // 不指定 path 参数则默认使用函数名称 /path2
path2(ctx: Context) {
return 'Hello path2';
}
@mapping({ path: '/p3' }) // 指定 path 值为 /p3
path3(ctx: Context) {
return 'Hello path3';
}
@mapping({ method: 'POST' }) // 指定请求方法
post(ctx: Context) {
return 'Hello post';
}
}
import { Context, Next, mapping, controller } from 'zenweb';
// 定义一个中间件处理函数
function actionLog(ctx: Context, next: Next) {
console.log('actionLog middleware')
return next();
}
export class Controller {
// 方法上的中间件
@mapping({ middleware: actionLog })
simple(ctx: Context) {
return 'simple';
}
}
// 控制器中间件,作用与所有控制器方法上
@controller({
middleware: actionLog,
})
export class Controller2 {
@mapping()
simple(ctx: Context) {
return 'simple';
}
}
FAQs
Zenweb Controller module
The npm package @zenweb/controller receives a total of 586 weekly downloads. As such, @zenweb/controller popularity was classified as not popular.
We found that @zenweb/controller demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.