0

SwaggerApi After sending data to my database, swagger keeps on loading in NESTJs. My responses are completely Ignored. The "IClientInterface" contains the feedback.

Controller for the POST endpoint is this: constroller.ts

@Post('account')
@ApiOperation({summary:'Create a new account'})
@ApiResponse({status:400, description: "Bad Request"})
@ApiResponse({status: 201, description:'Account created succesfully'})
async signUp( @Body() signUpDTO: SignUpDto ){
await this.userService.createUser(signUpDTO);
}
}

The service the post endpoint calls is this: service.ts

async createUser(payload:SignUpDto,) : Promise<IClientInterface>{
try{
payload.email =  payload.email.toLocaleLowerCase();
   const emailExists = await this.userRepostory.findOne({where:{email:payload.email}});
   if(emailExists){
    return feedBack({
        error:true,
        errorMessage: `email ${payload.email} already exists.`,
        statusCode:400
    })
   }
const userData = plainToClass(UserEntity,payload);
userData.createdBy = payload.email;
userData.email = payload.email;
userData.date =  new Date();
const saveUser = await this.userRepostory.save(userData);
if(saveUser && saveUserPass){
     return feedBack({
    statusCode:201,
    error:false,
    errorMessage:null,
    sucessMessage: `${userData.email} succesfully created`
 })
}
}
catch(error){
 return ({
        statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
        errorMessage: `Error while creating user - Error: ${error.message}`,
        error: true
      });
}
}

0 Answers0