Skip to content

Commit

Permalink
Remove boolean ssl option
Browse files Browse the repository at this point in the history
  • Loading branch information
moisses89 committed Jan 9, 2024
1 parent f1e1ce6 commit 155ca44
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ ADMIN_PASSWORD=password
WEBHOOKS_CACHE_TTL=300000
NODE_ENV=dev
SSE_AUTH_TOKEN=aW5mcmFAc2FmZS5nbG9iYWw6YWJjMTIz
ENABLE_DB_SSL=false
DB_SSL_ENABLE=false
# DB_CA_PATH=/path/of/db/certificate
# URL_BASE_PATH=/test # Set a globlal url path
39 changes: 17 additions & 22 deletions src/datasources/db/database.options.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Webhook } from '../../routes/webhook/entities/webhook.entity';
import { DataSourceOptions } from 'typeorm';
import * as fs from 'fs';

import { readFileSync } from 'fs';
/**
* Use process.env for configuration instead of Nest.js ConfigService
* as it cannot be used by TypeORM CLI to generate and run migrations
Expand All @@ -11,23 +10,19 @@ export const dataSourceOptions: DataSourceOptions = {
url: process.env.MIGRATIONS_DATABASE_URL,
entities: [Webhook],
migrations: [__dirname + '/../migrations/**/*{.ts,.js}'],
... (process.env.DB_SSL_ENABLE == 'true' ? {
ssl: true,
... (process.env.DB_CA_PATH ? {
extra: {
ssl: {
ca: fs.readFileSync(process.env.DB_CA_PATH),
rejectUnauthorized: true
}
}
} : {
extra: {
ssl: {
rejectUnauthorized: false
}
}
})
}:{
ssl: false
})
};
extra:
process.env.DB_SSL_ENABLE !== 'true'
? {}
: process.env.DB_CA_PATH
? {
ssl: {
ca: readFileSync(process.env.DB_CA_PATH),
rejectUnauthorized: true,
},
}
: {
ssl: {
rejectUnauthorized: false,
},
},
};

0 comments on commit 155ca44

Please sign in to comment.