You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

44 lines
1.4 KiB

// @ts-nocheck
/**
* 方法
* @param opts 参数
*/
type TMethod = "GET" | "POST" | "PUT" | "DELETE"
export function method(opts?: TMethod | Array<TMethod>) {
return function (target, propertyKey: string, descriptor: PropertyDescriptor) {
target[propertyKey].$method = opts
}
}
export function route(route?: string) {
return function (target, propertyKey: string, descriptor: PropertyDescriptor) {
target[propertyKey].$route = route
}
}
export function route_path(route_path?: string) {
return function (target, propertyKey: string, descriptor: PropertyDescriptor) {
target[propertyKey].$route_path = route_path
}
}
export function config(options: Object) {
return function (target, propertyKey: string, descriptor: PropertyDescriptor) {
target[propertyKey].$options = options
}
}
export function auth(isAuth: boolean | "try" | "required" | "optional" = true) {
return function (target, propertyKey: string, descriptor: PropertyDescriptor) {
target[propertyKey].$auth = isAuth
}
}
export function validate(validate: Object) {
return function (target, propertyKey: string, descriptor: PropertyDescriptor) {
target[propertyKey].$validate = validate
}
}
export function swagger(desc, notes, tags) {
return function (target, propertyKey: string, descriptor: PropertyDescriptor) {
target[propertyKey].$swagger = [desc, notes, tags]
}
}