1.1.31 • Published 2 years ago
@yuriyempty/nestjs-extended-controller v1.1.31
nestjs-extended-controller
Description
ExtendedController is a wrapper for "@nestjs/common/decorators/core/controller.decorator". With its help, you can inherit the behavior of the parent controller.
Example
First, we must create a parent controller
import { Controller } from "@nestjs/common";
@Controller("api")
export class AppController {}
Then create a child and assign a parent
import { Get, Param } from "@nestjs/common";
import { AppController } from "./app.controller";
import { ExtendedController } from "@yuriyempty/nestjs-extended-controller";
@ExtendedController({
parent: AppController,
path: [ "user", ":id" ]
})
export class UserController {
@Get()
public get(@Param() params): object {
return {
response: `response form route api/user/${ params.id }`
}
}
@Get("update")
public update(@Param() params): object {
return {
response: `response form route api/user/${ params.id }/update`
}
}
}
Also to param "parent" we can passed other "ExtendedController"
import { Get, Param } from "@nestjs/common";
import { UserController } from "./user.controller";
import { ExtendedController } from "@yuriyempty/nestjs-extended-controller";
@ExtendedController({
parent: UserController,
path: "profile"
})
export class ProfileController {
@Get()
public get(@Param() params): object {
return {
response: `response from route api/user/${ params.id }/profile`
}
}
@Get("update")
public update(@Param() params): object {
return {
response: `response from api/user/${ params.id }/profile/update`
}
}
}
Options
Name | Type | Default | Description |
---|---|---|---|
parent | Function | Controller | The parent class from which the behavior will be inherited |
path | string, string[] | "" | Inherits https://docs.nestjs.com/controllers#routing |
inheritRoutes | boolean | true | |
inheritHost | boolean | true | |
inheritScope | boolean | true | |
inheritGuards | boolean | true | |
inheritPipes | boolean | true | |
inheritExceptionFilters | boolean | true | |
inheritInterceptors | boolean | true |
TODO
1.1.30
2 years ago
1.1.31
2 years ago
1.1.29
3 years ago
1.1.28
3 years ago
1.1.27
3 years ago
1.1.26
3 years ago
1.1.25
3 years ago
1.0.25
3 years ago
1.0.24
3 years ago
1.0.23
3 years ago
1.0.19
3 years ago
1.0.18
3 years ago
1.0.17
3 years ago
1.0.16
3 years ago
1.0.22
3 years ago
1.0.21
3 years ago
1.0.20
3 years ago
1.0.15
3 years ago
1.0.14
3 years ago
1.0.13
3 years ago
1.0.12
3 years ago
1.0.11
3 years ago
1.0.10
3 years ago
1.0.9
3 years ago
1.0.8
3 years ago
1.0.7
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago