import { inject , lifeCycleObserver , LifeCycleObserver , ValueOrPromise , } from '@loopback/core' ; import { juggler } from '@loopback/repository' ; const config = { name : 'chatDb' , connector : 'postgresql' , url : '' , host : process . env . DB_HOST , port : process . env . DB_PORT , user : process . env . DB_USER , password : process . env . DB_PASSWORD , database : process . env . DB_DATABASE , } ; @ lifeCycleObserver ( 'datasource' ) export class PgdbDataSource extends juggler . DataSource implements LifeCycleObserver { static dataSourceName = 'chatDb' ; constructor ( @ inject ( 'datasources.config.Chat' , { optional : true } ) dsConfig = config ) { super ( dsConfig ) ; } /**
     * Start the datasource when application is started
     */ start ( ) { } /**
     * Disconnect the datasource when application is stopped. This allows the
     * application to be shut down gracefully.
     */ stop ( ) { return super . disconnect ( ) ; } }