Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: allow to pick up entities from shared libraries #220

Merged
merged 1 commit into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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