digjoy
Version:
Simple Typescript decorators for express routing with joi validation
23 lines • 1.87 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DELETE = exports.HEAD = exports.TRACE = exports.CONNECT = exports.OPTIONS = exports.PUT = exports.POST = exports.PATCH = exports.GET = void 0;
require("reflect-metadata");
var HttpMethods_1 = require("../constants/HttpMethods");
var Metadatas_1 = require("../constants/Metadatas");
function createMethodHandler(method, path, schema) {
return function (target, propertyKey, descriptor) {
Reflect.defineMetadata(Metadatas_1.Metadatas.Path, path, target, propertyKey);
Reflect.defineMetadata(Metadatas_1.Metadatas.Schema, schema, target, propertyKey);
Reflect.defineMetadata(Metadatas_1.Metadatas.Method, method, target, propertyKey);
};
}
exports.GET = function (path, schema) { return createMethodHandler(HttpMethods_1.HttpMethods.GET, path, schema); };
exports.PATCH = function (path, schema) { return createMethodHandler(HttpMethods_1.HttpMethods.PATCH, path, schema); };
exports.POST = function (path, schema) { return createMethodHandler(HttpMethods_1.HttpMethods.POST, path, schema); };
exports.PUT = function (path, schema) { return createMethodHandler(HttpMethods_1.HttpMethods.PUT, path, schema); };
exports.OPTIONS = function (path, schema) { return createMethodHandler(HttpMethods_1.HttpMethods.OPTIONS, path, schema); };
exports.CONNECT = function (path, schema) { return createMethodHandler(HttpMethods_1.HttpMethods.CONNECT, path, schema); };
exports.TRACE = function (path, schema) { return createMethodHandler(HttpMethods_1.HttpMethods.TRACE, path, schema); };
exports.HEAD = function (path, schema) { return createMethodHandler(HttpMethods_1.HttpMethods.HEAD, path, schema); };
exports.DELETE = function (path, schema) { return createMethodHandler(HttpMethods_1.HttpMethods.DELETE, path, schema); };
//# sourceMappingURL=methods.js.map