Skip to content

Commit

Permalink
Adding export connection
Browse files Browse the repository at this point in the history
  • Loading branch information
VivekFitkariwala committed Jun 19, 2024
1 parent f002084 commit 4e7a6ee
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions backend/packages/Upgrade/src/loaders/typeormLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { SERVER_ERROR } from 'upgrade_types';
import { CONNECTION_NAME } from './enums';
import { PostgresConnectionCredentialsOptions } from 'typeorm/driver/postgres/PostgresConnectionCredentialsOptions';
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions.js';
import { Container } from 'typedi';
import { Container as tteContainer } from '../typeorm-typedi-extensions';

export const typeormLoader: MicroframeworkLoader = async (settings: MicroframeworkSettings | undefined) => {
Expand Down Expand Up @@ -54,7 +53,7 @@ export const typeormLoader: MicroframeworkLoader = async (settings: Microframewo
name: CONNECTION_NAME.REPLICA,
type: env.db.type as 'postgres',
replication: {
master: masterHost,
master: exportReplicaHost,
slaves: exportReplicaSlaves,
},
synchronize: env.db.synchronize,
Expand All @@ -71,12 +70,9 @@ export const typeormLoader: MicroframeworkLoader = async (settings: Microframewo

const exportDataSourceInstance = new DataSource(exportReplicaDBConnectionOptions);
// register the data source instance in the typeorm-typeDI-extensions
tteContainer.setDataSource(CONNECTION_NAME.MAIN, appDataSourceInstance);
tteContainer.setDataSource(CONNECTION_NAME.REPLICA, exportDataSourceInstance);
await Promise.all([appDataSourceInstance.initialize(), exportDataSourceInstance.initialize()]);

// adding the appDataSourceInstance in the typeDI
Container.set(CONNECTION_NAME.MAIN, appDataSourceInstance);
Container.set(CONNECTION_NAME.REPLICA, exportDataSourceInstance);

if (settings) {
// sending the connections to the next middleware
Expand Down

0 comments on commit 4e7a6ee

Please sign in to comment.