Skip to content

Commit

Permalink
change null coalescing operator from env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
rem1niscence committed Jul 13, 2021
1 parent 8860131 commit bddc518
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions src/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ export class PocketGatewayApplication extends BootMixin(ServiceMixin(RepositoryM
// Requirements; for Production these are stored in GitHub repo secrets
//
// For Dev, you need to pass them in via .env file
const environment: string = process.env.NODE_ENV ?? 'production'
const environment: string = process.env.NODE_ENV || 'production'

logger.log('info', 'Environment: ' + environment)

const dispatchURL: string = process.env.DISPATCH_URL ?? ''
const altruists: string = process.env.ALTRUISTS ?? ''
const clientPrivateKey: string = process.env.GATEWAY_CLIENT_PRIVATE_KEY ?? ''
const clientPassphrase: string = process.env.GATEWAY_CLIENT_PASSPHRASE ?? ''
const pocketSessionBlockFrequency: string = process.env.POCKET_SESSION_BLOCK_FREQUENCY ?? ''
const pocketBlockTime: string = process.env.POCKET_BLOCK_TIME ?? ''
const relayRetries: string = process.env.POCKET_RELAY_RETRIES ?? ''
const databaseEncryptionKey: string = process.env.DATABASE_ENCRYPTION_KEY ?? ''
const aatPlan = process.env.AAT_PLAN ?? AatPlans.PREMIUM
const dispatchURL: string = process.env.DISPATCH_URL || ''
const altruists: string = process.env.ALTRUISTS || ''
const clientPrivateKey: string = process.env.GATEWAY_CLIENT_PRIVATE_KEY || ''
const clientPassphrase: string = process.env.GATEWAY_CLIENT_PASSPHRASE || ''
const pocketSessionBlockFrequency: string = process.env.POCKET_SESSION_BLOCK_FREQUENCY || ''
const pocketBlockTime: string = process.env.POCKET_BLOCK_TIME || ''
const relayRetries: string = process.env.POCKET_RELAY_RETRIES || ''
const databaseEncryptionKey: string = process.env.DATABASE_ENCRYPTION_KEY || ''
const aatPlan = process.env.AAT_PLAN || AatPlans.PREMIUM

if (!dispatchURL) {
throw new HttpErrors.InternalServerError('DISPATCH_URL required in ENV')
Expand Down Expand Up @@ -144,8 +144,8 @@ export class PocketGatewayApplication extends BootMixin(ServiceMixin(RepositoryM
this.bind('redisInstance').to(redis)

// Load Postgres for TimescaleDB metrics
const pgConnection: string = process.env.PG_CONNECTION ?? ''
const pgCertificate: string = process.env.PG_CERTIFICATE ?? ''
const pgConnection: string = process.env.PG_CONNECTION || ''
const pgCertificate: string = process.env.PG_CERTIFICATE || ''

if (!pgConnection) {
throw new HttpErrors.InternalServerError('PG_CONNECTION required in ENV')
Expand Down
4 changes: 2 additions & 2 deletions src/services/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ interface Log {
elapsedTime: number
}

const environment: string = process.env.NODE_ENV ?? 'production'
const logzToken: string = process.env.LOGZ_TOKEN ?? ''
const environment: string = process.env.NODE_ENV || 'production'
const logzToken: string = process.env.LOGZ_TOKEN || ''

if (!logzToken && environment === 'production') {
throw new HttpErrors.InternalServerError('LOGZ_TOKEN required in ENV')
Expand Down

0 comments on commit bddc518

Please sign in to comment.