FEAT: network config module using in-factory

This commit is contained in:
Gabriel Rosa
2022-07-28 15:41:21 -03:00
parent 97214280bc
commit 43cec9b6fa
7 changed files with 138 additions and 33 deletions
@@ -1,6 +1,7 @@
import {
Body,
Controller,
Delete,
Get,
Inject,
Param,
@@ -14,6 +15,7 @@ import { RequestUser, User } from 'src/authentication/user.decorator';
import {
CreateNetworkConfigReq,
CreateNetworkConfigRes,
DeleteNetworkConfigRes,
FindAllNetworkConfigsRes,
UpdateNetworkConfigReq,
UpdateNetworkConfigRes,
@@ -39,6 +41,19 @@ export class NetworkConfigController {
return this.networkConfigService.findAllNetworkConfigs(user.customer_name);
}
@Get(':id')
@ApiOkResponse({ type: FindAllNetworkConfigsRes })
async findNetworkConfigById(
@User() user: RequestUser,
@Param('id') id: string,
) {
this.logger.info('GET /network-config/:id', {
user: user.user_id,
customer: user.customer_name,
});
return this.networkConfigService.findNetworkConfigById(id);
}
@Post()
@ApiOkResponse({ type: CreateNetworkConfigRes })
async createNetworkConfigs(
@@ -62,7 +77,7 @@ export class NetworkConfigController {
@Param('id') network_config_id: string,
@Body() body: UpdateNetworkConfigReq,
) {
this.logger.info('POST /network-config', {
this.logger.info('PATCH /network-config/:id', {
user: user.user_id,
customer: user.customer_name,
});
@@ -72,16 +87,16 @@ export class NetworkConfigController {
);
}
@Get(':id')
@ApiOkResponse({ type: FindAllNetworkConfigsRes })
async findNetworkConfigById(
@Delete(':id')
@ApiOkResponse({ type: DeleteNetworkConfigRes })
async deleteNetworkConfig(
@User() user: RequestUser,
@Param('id') id: string,
@Param('id') network_config_id: string,
) {
this.logger.info('GET /network-config', {
this.logger.info('DELETE /network-config', {
user: user.user_id,
customer: user.customer_name,
});
return this.networkConfigService.findNetworkConfigById(id);
return this.networkConfigService.deleteNetworkConfig(network_config_id);
}
}