@tsed/schema
Version:
JsonSchema module for Ts.ED Framework
147 lines (146 loc) • 6.61 kB
JavaScript
import { OperationVerbs } from "../../constants/OperationVerbs.js";
import { Operation } from "./operation.js";
/**
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
*
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
* For example, if you placed the following route at the top of all other route definitions, it would require that
* all routes from that point on would require authentication, and automatically load a user.
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
* to continue matching subsequent routes.
* @param path
* @param args
* @returns {Function}
* @decorator
* @operation
* @httpMethod
*/
export function All(path = "/", ...args) {
return Operation(...[OperationVerbs.ALL, path].concat(args));
}
/**
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
*
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
* For example, if you placed the following route at the top of all other route definitions, it would require that
* all routes from that point on would require authentication, and automatically load a user.
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
* to continue matching subsequent routes.
* @param path
* @param args
* @returns {Function}
* @decorator
* @operation
* @httpMethod
*/
export function Get(path = "/", ...args) {
return Operation(...[OperationVerbs.GET, path].concat(args));
}
/**
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
*
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
* For example, if you placed the following route at the top of all other route definitions, it would require that
* all routes from that point on would require authentication, and automatically load a user.
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
* to continue matching subsequent routes.
* @param path
* @param args
* @returns {Function}
* @decorator
* @operation
* @httpMethod
*/
export function Post(path = "/", ...args) {
return Operation(...[OperationVerbs.POST, path].concat(args));
}
/**
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
*
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
* For example, if you placed the following route at the top of all other route definitions, it would require that
* all routes from that point on would require authentication, and automatically load a user.
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
* to continue matching subsequent routes.
* @param path
* @param args
* @returns {Function}
* @decorator
* @operation
* @httpMethod
*/
export function Put(path = "/", ...args) {
return Operation(...[OperationVerbs.PUT, path].concat(args));
}
/**
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
*
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
* For example, if you placed the following route at the top of all other route definitions, it would require that
* all routes from that point on would require authentication, and automatically load a user.
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
* to continue matching subsequent routes.
* @param path
* @param args
* @returns {Function}
* @decorator
* @operation
* @httpMethod
*/
export function Delete(path = "/", ...args) {
return Operation(...[OperationVerbs.DELETE, path].concat(args));
}
/**
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
*
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
* For example, if you placed the following route at the top of all other route definitions, it would require that
* all routes from that point on would require authentication, and automatically load a user.
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
* to continue matching subsequent routes.
* @param path
* @param args
* @returns {Function}
* @decorator
* @operation
* @httpMethod
*/
export function Head(path = "/", ...args) {
return Operation(...[OperationVerbs.HEAD, path].concat(args));
}
/**
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
*
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
* For example, if you placed the following route at the top of all other route definitions, it would require that
* all routes from that point on would require authentication, and automatically load a user.
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
* to continue matching subsequent routes.
* @param path
* @param args
* @returns {Function}
* @decorator
* @operation
* @httpMethod
*/
export function Patch(path = "/", ...args) {
return Operation(...[OperationVerbs.PATCH, path].concat(args));
}
/**
* This method is just like the `router.METHOD()` methods, except that it matches all HTTP methods (verbs).
*
* This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches.
* For example, if you placed the following route at the top of all other route definitions, it would require that
* all routes from that point on would require authentication, and automatically load a user.
* Keep in mind that these callbacks do not have to act as end points; loadUser can perform a task, then call next()
* to continue matching subsequent routes.
* @param path
* @param args
* @returns {Function}
* @decorator
* @operation
* @httpMethod
*/
export function Options(path = "/", ...args) {
return Operation(...[OperationVerbs.OPTIONS, path].concat(args));
}