#ConfigService doesn't work with TypeOrm.forRootAsync()

1 messages · Page 1 of 1 (latest)

vestal ivy
#

but when i'm using configService

return {
            type: 'postgres',
            host: configService.get<string>('DB_HOST', 'localhost'),
            port: configService.get<number>('DB_PORT', 5432),
            username: configService.get<string>('DB_USERNAME'),
            password: configService.get<string>('DB_PASSWORD'),
            database: configService.get<string>('DB_DATABASE_NAME'),
            entities: [],
            synchronize: true,
            logging: true
        };

.env

DB_HOST=localhost,
DB_PORT=5432,
DB_USERNAME=postgres,
DB_PASSWORD=some-password,
DB_DATABASE_NAME=postgres
#

I have an error

[Nest] 15300  - 18.06.2023, 13:08:42   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (9)...
Error: getaddrinfo ENOTFOUND localhost,
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) 
proud scroll
#

I don't think the useFactory function should be async?

#

there is also no await

#

so what it does, async force to return a promise which is not expected maybe

#

it gets wrapped in a promise by nest I would assume