1.0.2 • Published 3 years ago
@stringke/midway-pro v1.0.2
midwayjs-pro
npm i @stringke/midwayjs-proyarn add @stringke/midwayjs-proimport * as pro from '@stringke/midwayjs-pro';
/// 请在 configuration 里引入介绍
提供了一些基础的功能,可以让你快速的开发一个项目。
ApiString,ApiNumber,ApiBoolean用于控制器上具体某个方法参数定义ApiController,ApiQuery,ApiBody,ApiParam,ApiHeader用于具体参数的定义DtoString,DtoNumber,DtoBoolean,DtoClass用于 dto 的基本验证,同时如果传递了 require 会自动拼接对应验证效果BaseMiddleware,BaseController控制器和中间件可以继承这两个获得更多功能- 已经封装了错误,你可以继承
BusinnessError来自定义错误 nanoid,getUrlId,getDataId用于生产 IDapplyDecorators用来快速合并装饰器
demo
import { ApiController, ApiQuery } from "./decorators";
@ApiController('/api')
class UserController {
@ApiGet("/user", GetUserRes)
async getUserInfo(@ApiQuery() id: number) {
return {
id: 1
}
}
}