Skip to content

Commit

Permalink
chore: allow to pick up entities from shared libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
kgajowy committed May 31, 2021
1 parent 51ad350 commit fbf3f12
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
13 changes: 10 additions & 3 deletions api/apps/api/src/ormconfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as path from 'path';
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions';
import { AppConfig } from './utils/config.utils';
import { AppConfig } from '@marxan-api/utils/config.utils';
import { DbConnections } from './ormconfig.connections';

/**
Expand All @@ -26,7 +27,10 @@ export const apiConnections: Record<
type: 'postgres',
url: AppConfig.get('postgresApi.url'),
ssl: false,
entities: [__dirname + '/modules/**/*.api.entity.{ts,js}'],
entities: [
path.join(__dirname, '/modules/**/*.api.entity.{ts,js}'),
path.join(__dirname, '../../../libs/**/*.api.entity.{ts,js}'),
],
// Logging may be: ['query', 'error', 'schema', 'warn', 'info', 'log'] Use
// 'query' if needing to see the actual generated SQL statements (this should
// be limited to `NODE_ENV=development`). Use 'error' for least verbose
Expand Down Expand Up @@ -57,7 +61,10 @@ export const apiConnections: Record<
type: 'postgres',
url: AppConfig.get('postgresGeoApi.url'),
ssl: false,
entities: [__dirname + '/modules/**/*.geo.entity.{ts,js}'],
entities: [
path.join(__dirname, '/modules/**/*.geo.entity.{ts,js}'),
path.join(__dirname, '../../../libs/**/*.geo.entity.{ts,js}'),
],
logging: ['error'],
cache: false,
// Migrations for this db/data source are handled in the geoprocessing
Expand Down
11 changes: 9 additions & 2 deletions api/apps/geoprocessing/src/ormconfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as path from 'path';
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions';
import { AppConfig } from '@marxan-geoprocessing/utils/config.utils';

Expand All @@ -22,7 +23,10 @@ export const geoprocessingConnections: {
type: 'postgres',
url: AppConfig.get('postgresGeoApi.url'),
ssl: false,
entities: [__dirname + '/modules/**/*.geo.entity.{ts,js}'],
entities: [
path.join(__dirname, '/modules/**/*.geo.entity.{ts,js}'),
path.join(__dirname, '../../../libs/**/*.geo.entity.{ts,js}'),
],
// Logging may be: ['query', 'error', 'schema', 'warn', 'info', 'log'] Use
// 'query' if needing to see the actual generated SQL statements (this should
// be limited to `NODE_ENV=development`). Use 'error' for least verbose
Expand All @@ -46,7 +50,10 @@ export const geoprocessingConnections: {
type: 'postgres',
url: AppConfig.get('postgresApi.url'),
ssl: false,
entities: [__dirname + '/modules/**/*.api.entity.{ts,js}'],
entities: [
__dirname + '/modules/**/*.api.entity.{ts,js}',
path.join(__dirname, '../../../libs/**/*.api.entity.{ts,js}'),
],
// Logging may be: ['query', 'error', 'schema', 'warn', 'info', 'log'] Use
// 'query' if needing to see the actual generated SQL statements (this should
// be limited to `NODE_ENV=development`). Use 'error' for least verbose
Expand Down

0 comments on commit fbf3f12

Please sign in to comment.