nestjs / typeorm

TypeORM module for Nest framework (node.js) 🍇
https://nestjs.com
MIT License
1.93k stars 206 forks source link

perhaps Typeorm module didn't passing request response to controller #1903

Closed Samandar02 closed 9 months ago

Samandar02 commented 9 months ago

Is there an existing issue for this?

Current behavior

i am developing NestJs application now and i have one issue when i serve application in local PC it works correctly but whenever I serve it inside of docker, request and response both undefined on POST method

@ApiTags('bank')
@Controller('/bank')
export class AppClientController {
    constructor(private clientSvc: AppClientService) { }
    @Post('scoring')
    async scoring(@Body() client: ProfileDto, @Req() req:Request,@Res() res:Response) {
        console.log(JSON.stringify(client)) // undefined
        console.log(req) // undefined
        console.log(res) // undefined
        let result = await this.clientSvc.startScoringProcess(client)
        return result;
    }

when I remove TypeOrmModule it works correctly as I expect

here is TypeOrm module

TypeOrmModule.forRoot({
    type: 'postgres',
    host: procces.env.DB_HOST,
    port: +procces.env.DB_PORT,
    database: procces.env.DB_DATABASE,
    username: procces.env.DB_USERNAME,
    password: procces.env.DB_PASSWORD,
    schema: procces.env.DB_SCHEMA,
    entities: [
      BankCustomerEntity,
      BankScoringEntity,
      BankOperDayEntity,
      LoanApplicationEntity,
      LoanContractEntity,
      LoanContractGuarEntity,
      BankAutopayEntity,
      LoanScheduleEntity,
      LoanScheduleDataEntity,
      ProcessEntity
    ],
    logging: false,
    autoLoadEntities: true,
    synchronize: false,
})

node version: v20.11.0 nestjs version: 10.1.18 nestjs/typeorm version: 10.0.2

Expected behavior

request and response should not be undefined

Package version

10.0.2

NestJS version

10.1.18

Node.js version

20.11.0

In which operating systems have you tested?

Other

No response

micalevisk commented 9 months ago

this is mentioned in the docs here: https://docs.nestjs.com/controllers#library-specific-approach

you can use @Res({ passthrough: true })

Samandar02 commented 9 months ago

Ok thanks @micalevisk , my issue has resolved by upgrading reflect-metadata package version from 0.1.13 to 0.2.0