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')