From e8c475df948df054c2f30a8cdff66a4178f1985d Mon Sep 17 00:00:00 2001 From: barthofu Date: Tue, 2 Apr 2024 18:46:19 +0000 Subject: [PATCH] fix(env): mikro-orm commands not getting env variables (#161) --- mikro-orm.config.ts | 6 ++++-- src/utils/types/environment.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mikro-orm.config.ts b/mikro-orm.config.ts index 43b4a0fa..57eb8715 100644 --- a/mikro-orm.config.ts +++ b/mikro-orm.config.ts @@ -1,9 +1,11 @@ // @ts-nocheck +import 'reflect-metadata' + +import process from 'node:process' import { Options } from '@mikro-orm/core' import * as entities from '@/entities' -import { env } from '@/env' import { PluginsManager } from '@/services' import { resolveDependency } from '@/utils/functions' @@ -14,7 +16,7 @@ export default async () => { await pluginsManager.loadPlugins() return { - ...mikroORMConfig[env.NODE_ENV || 'development'] as Options, + ...mikroORMConfig[process.env.NODE_ENV || 'development'] as Options, entities: [...Object.values(entities), ...pluginsManager.getEntities()], } } diff --git a/src/utils/types/environment.ts b/src/utils/types/environment.ts index 11eb0f84..3297cff5 100644 --- a/src/utils/types/environment.ts +++ b/src/utils/types/environment.ts @@ -5,7 +5,7 @@ import { cleanEnv, num, str } from 'envalid' import { apiConfig, generalConfig, mikroORMConfig } from '@/configs' export const env = cleanEnv(process.env, { - NODE_ENV: str({ choices: ['development', 'production'] }), + NODE_ENV: str({ choices: ['development', 'production'], default: 'development' }), BOT_TOKEN: str(), TEST_GUILD_ID: str(),