@tsed/common
Version:
A TypeScript Framework on top of Express
49 lines • 1.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RawPathParams = exports.PathParams = void 0;
const ParamTypes_1 = require("../../models/ParamTypes");
const mapParamsOptions_1 = require("../../utils/mapParamsOptions");
const useParam_1 = require("./useParam");
function PathParams(...args) {
const { expression, useType, useConverter = true, useValidation = true } = mapParamsOptions_1.mapParamsOptions(args);
return useParam_1.UseParam(ParamTypes_1.ParamTypes.PATH, {
expression,
useType,
useConverter,
useValidation
});
}
exports.PathParams = PathParams;
/**
* RawPathParams return the raw value from [request.params](http://expressjs.com/en/4x/api.html#req.params) object.
*
* Any validation and transformation are performed on the value. Use [pipes](/docs/pipes.html) to validate and/or transform the value.
*
* #### Example
*
* ```typescript
* @Controller('/')
* class MyCtrl {
* @Get('/')
* get(@RawPathParams() params: string) {
* console.log('Entire params', params);
* }
*
* @Get('/')
* get(@RawPathParams('id') id: string) {
* console.log('ID', id);
* }
* }
* ```
* > For more information on deserialization see [converters](/docs/converters.md) page.
*
* @param expression The path of the property to get.
* @decorator
* @operation
* @input
*/
function RawPathParams(expression) {
return useParam_1.UseParam(ParamTypes_1.ParamTypes.PATH, { expression });
}
exports.RawPathParams = RawPathParams;
//# sourceMappingURL=pathParams.js.map