plc: run dotenv before any other imports
This fixes, eg, logging configuration via .env variables.
This commit is contained in:
parent
8b803e013c
commit
7b5f8906d1
@ -1,15 +1,8 @@
|
||||
import dotenv from 'dotenv'
|
||||
import './env'
|
||||
import { Database } from './server/db'
|
||||
import PlcServer from './server'
|
||||
|
||||
const run = async () => {
|
||||
const env = process.env.ENV
|
||||
if (env) {
|
||||
dotenv.config({ path: `./.${env}.env` })
|
||||
} else {
|
||||
dotenv.config()
|
||||
}
|
||||
|
||||
const dbLoc = process.env.DATABASE_LOC
|
||||
const dbPostgresUrl = process.env.DB_POSTGRES_URL
|
||||
|
||||
|
9
packages/plc/src/env.ts
Normal file
9
packages/plc/src/env.ts
Normal file
@ -0,0 +1,9 @@
|
||||
// NOTE: this file should be imported first, particularly before `@atproto/common` (for logging), to ensure that environment variables are respected in library code
|
||||
import dotenv from 'dotenv'
|
||||
|
||||
const env = process.env.ENV
|
||||
if (env) {
|
||||
dotenv.config({ path: `./.${env}.env` })
|
||||
} else {
|
||||
dotenv.config()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user