1.1.31 • Published 3 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
3 years ago
1.1.31
3 years ago
1.1.29
4 years ago
1.1.28
4 years ago
1.1.27
4 years ago
1.1.26
4 years ago
1.1.25
4 years ago
1.0.25
4 years ago
1.0.24
4 years ago
1.0.23
4 years ago
1.0.19
4 years ago
1.0.18
4 years ago
1.0.17
4 years ago
1.0.16
4 years ago
1.0.22
4 years ago
1.0.21
4 years ago
1.0.20
4 years ago
1.0.15
4 years ago
1.0.14
4 years ago
1.0.13
4 years ago
1.0.12
4 years ago
1.0.11
4 years ago
1.0.10
4 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.7
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago