From b6e4f9766884cc648abc0001a16206ed55670a83 Mon Sep 17 00:00:00 2001 From: k00b Date: Wed, 28 Aug 2024 09:34:24 -0500 Subject: [PATCH] fix env loading in worker --- worker/index.js | 6 ++---- worker/loadenv.js | 3 +++ 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 worker/loadenv.js diff --git a/worker/index.js b/worker/index.js index a1f91fa6..759d6ad7 100644 --- a/worker/index.js +++ b/worker/index.js @@ -1,5 +1,6 @@ +// environment variables are loaded from files and imports run before the rest of the code +import './loadenv.js' import PgBoss from 'pg-boss' -import nextEnv from '@next/env' import createPrisma from '@/lib/create-prisma.js' import { autoDropBolt11s, checkInvoice, checkPendingDeposits, checkPendingWithdrawals, @@ -34,11 +35,8 @@ import { import { thisDay } from './thisDay.js' import { isServiceEnabled } from '@/lib/sndev.js' -const { loadEnvConfig } = nextEnv const { ApolloClient, HttpLink, InMemoryCache } = apolloClient -loadEnvConfig('.', process.env.NODE_ENV === 'development') - async function work () { const boss = new PgBoss(process.env.DATABASE_URL) const models = createPrisma({ diff --git a/worker/loadenv.js b/worker/loadenv.js new file mode 100644 index 00000000..d05d0614 --- /dev/null +++ b/worker/loadenv.js @@ -0,0 +1,3 @@ +import nextEnv from '@next/env' +const { loadEnvConfig } = nextEnv +loadEnvConfig('.', process.env.NODE_ENV === 'development')