From af8fa7237798f4540618bcf94a10906cc19c2eb8 Mon Sep 17 00:00:00 2001 From: marcos-silva-rodrigues Date: Thu, 9 Jan 2025 08:40:02 -0300 Subject: [PATCH] FIX: add header content type and change status code to 200 --- src/modules/open-data/open-data.controller.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/modules/open-data/open-data.controller.ts b/src/modules/open-data/open-data.controller.ts index c911924..975d0da 100644 --- a/src/modules/open-data/open-data.controller.ts +++ b/src/modules/open-data/open-data.controller.ts @@ -1,5 +1,5 @@ import DadosferaLogger from '@dadosfera/dadosfera-logs'; -import { Body, Controller, Inject, Param, Post, Query, Req, UseFilters, UseGuards } from '@nestjs/common'; +import { Body, Controller, Header, HttpCode, Inject, Param, Post, Query, Req, UseFilters, UseGuards } from '@nestjs/common'; import { ApiCreatedResponse, ApiHeaders, ApiOkResponse, ApiTags } from '@nestjs/swagger'; import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator'; import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter'; @@ -33,6 +33,8 @@ export class OpenDataController { @Post("/sharing-ocean-data") // @SetOrigin('devsbm.dadosfera.io') // @UseGuards(CORSGuard) + @HttpCode(200) + @Header('content-type', 'application/json') @ApiOkResponse() async createUser( @Body() @@ -84,16 +86,18 @@ export class OpenDataController { this.logger.info('user request' + JSON.stringify({ user, roles, customer: OPENDATA_CUSTOMER_ID })); try { - const response = await this.openDataService.createUser(OPENDATA_CUSTOMER_ID, user, roles, metadata); - this.logger.info('user created with sucessfull data' + JSON.stringify(response)); + await this.openDataService.createUser(OPENDATA_CUSTOMER_ID, user, roles, metadata); + this.logger.info('user created with sucessfull data'); return { success: true, + status: 'success', message: 'user created with succesfull' } } catch (e) { - this.logger.error('user data' + e.message); + this.logger.error('failed with exception: ' + e.message); return { success: false, + status: 'failed', message: e.message }; }