Skip to content

Commit

Permalink
chore: Update S3 configuration in migrator.ts
Browse files Browse the repository at this point in the history
The code changes in migrator.ts update the S3 configuration by adding default values for S3_ENDPOINT, S3_ACCESS_HOST, S3_BUCKET, and S3_REGION. This ensures that the migrator script can run without any missing or undefined environment variables.
  • Loading branch information
OXeu committed Jun 7, 2024
1 parent a9bed93 commit f597ee0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions scripts/migrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { $ } from "bun"
import { readdir } from "node:fs/promises"
import stripIndent from 'strip-indent'


function env(name: string, defaultValue?: string, required = false) {
const env = process.env
const value = env[name] || defaultValue
Expand All @@ -11,18 +10,20 @@ function env(name: string, defaultValue?: string, required = false) {
}
return value
}

// must be defined
const renv = (name: string, defaultValue?: string) => env(name, defaultValue, true)

const DB_NAME = renv("DB_NAME", 'rin')
const WORKER_NAME = renv("WORKER_NAME", 'rin-server')
const FRONTEND_URL = env("FRONTEND_URL", "")

const S3_ENDPOINT = renv("S3_ENDPOINT")
const S3_ACCESS_HOST = renv("S3_ACCESS_HOST", S3_ENDPOINT)
const S3_BUCKET = renv("S3_BUCKET")
const S3_ENDPOINT = env("S3_ENDPOINT", "")
const S3_ACCESS_HOST = env("S3_ACCESS_HOST", S3_ENDPOINT)
const S3_BUCKET = env("S3_BUCKET", "")
const S3_CACHE_FOLDER = renv("S3_CACHE_FOLDER", 'cache/')
const S3_FOLDER = renv("S3_FOLDER", 'images/')
const S3_REGION = renv("S3_REGION")
const S3_REGION = renv("S3_REGION", "auto")

// Secrets
const accessKeyId = env("S3_ACCESS_KEY_ID")
Expand Down

0 comments on commit f597ee0

Please sign in to comment.