Skip to content

Commit

Permalink
Merge pull request #7 from trade-tariff/BAU-tweaks
Browse files Browse the repository at this point in the history
BAU: Small changes to workflows and environment
  • Loading branch information
willfish authored Mar 25, 2024
2 parents b43745e + e13b8e8 commit 41c26bf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ executors:
jobs:
linters:
docker:
- image: cimg/node:20.11.0
- image: cimg/node:21.6.2
resource_class: small
steps:
- checkout
Expand Down
4 changes: 2 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import initEnvironment from './config/env'
import { CustomerApiKeyRepository } from './repositories/customerApiKeyRepository'
initEnvironment()

const _client = new DynamoDBClient({ region: process.env.AWS_REGION })
const client = new DynamoDBClient({ region: process.env.AWS_REGION })
// TODO: Pass this around to the relevant controllers
const _repository = new CustomerApiKeyRepository(_client)
const _repository = new CustomerApiKeyRepository(client)

const app: Express = express()
const isDev = app.get('env') === 'development'
Expand Down
16 changes: 9 additions & 7 deletions src/config/env.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
const dotenv = require('dotenv')
const path = require('path')
const fs = require('fs')
import dotenv from 'dotenv'
import path from 'path'
import fs from 'fs'

export default function initEnvironment (): void {
let envFilePath = path.join(process.cwd(), '.env')
let envFilePath: string

switch (process.env.NODE_ENV) {
case 'production':
envFilePath = path.join(process.cwd(), '.env')
break
case 'test':
envFilePath = path.join(process.cwd(), '.env.test')
break
case 'development':
default:
envFilePath = path.join(process.cwd(), '.env.development')
break
}

if (fs.existsSync(envFilePath) === true) {
if (fs.existsSync(envFilePath)) {
dotenv.config({ path: envFilePath })
} else {
console.warn(`Environment file not found: ${envFilePath}`)
Expand Down

0 comments on commit 41c26bf

Please sign in to comment.