# Decorator PathParams
Decorator operation inputModule | import { PathParams } from "@tsed/common" |
---|---|
Source | /packages/common/src/mvc/decorators/params/pathParams.ts |
# Overview
function PathParams(expression: string, useType: Type<any>): ParameterDecorator;
export function PathParams(expression: string): ParameterDecorator;
export function PathParams(useType: Type<any>): ParameterDecorator;
export function PathParams(options: IParamOptions<any>): ParameterDecorator;
export function PathParams(): ParameterDecorator;
Param | Type | Description |
---|---|---|
expression | string | The path of the property to get. useType |
# Description
PathParams return the value from request.params (opens new window) object.
# Example
@Controller('/')
class MyCtrl {
@Get('/')
get(@PathParams() params: any) {
console.log('Entire params', params);
}
@Get('/')
get(@PathParams('id') id: string) {
console.log('ID', id);
}
@Get('/')
get(@PathParams({expression: 'id', useType: () => new MyCustomModel() }) id: string) {
console.log('ID', id);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
For more information on deserialization see converters page.
Other topics
- Session & cookies
- Passport.js
- Keycloak
- TypeORM
- Mongoose
- GraphQL
- Socket.io
- Swagger
- AJV
- Multer
- Serve static files
- Templating
- AWS
- Seq
- OIDC
- Stripe
- Controllers
- Providers
- Model
- JsonMapper
- Middlewares
- Pipes
- Interceptors
- Authentication
- Hooks
- Exceptions
- Throw HTTP Exceptions
- Cache
- Hooks
- Response Filter
- Injection scopes
- Custom providers
- Custom endpoint decorator
- Testing
- Customize 404