Skip to content

Commit

Permalink
fix(env): mikro-orm commands not getting env variables (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
barthofu committed Apr 2, 2024
1 parent 2fb64ae commit e8c475d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions mikro-orm.config.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -14,7 +16,7 @@ export default async () => {
await pluginsManager.loadPlugins()

return {
...mikroORMConfig[env.NODE_ENV || 'development'] as Options<DatabaseDriver>,
...mikroORMConfig[process.env.NODE_ENV || 'development'] as Options<DatabaseDriver>,
entities: [...Object.values(entities), ...pluginsManager.getEntities()],
}
}
2 changes: 1 addition & 1 deletion src/utils/types/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit e8c475d

Please sign in to comment.