How can I periodically generate db connection password with nestjs + typeorm?

Viewed 206

I followed this instruction (https://docs.nestjs.com/techniques/database) to setup the Postgresql database connection with nestjs. I created a class to provide the connection options like:

export class PostgreeSql implements TypeOrmOptionsFactory{
   async createTypeOrmOptions(): Promise<TypeOrmModuleOptions> {
       const signer = new AWS.RDS.Signer(...)
       signer.getAuthToken({}, (err, token) => {
    ...
}

In the above method createTypeOrmOptions, it generates the password which is valid for 15 minutes. It works fine for the 15 minutes but after the password token expire, I will get authorization error response in my application. I have a scheduler to generate a new password every 15 minutes but How can I force nestjs to reconnect with a new connect options?

0 Answers
Related