From ae0ffa9894abe803bd13438b81e3c8556e5d4d5a Mon Sep 17 00:00:00 2001 From: William Oldham Date: Sun, 5 Nov 2023 15:12:36 +0000 Subject: [PATCH] Add ORM Specific config --- src/config/orm.ts | 20 ++++++++++++++++++++ src/mikro-orm.config.ts | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src/config/orm.ts diff --git a/src/config/orm.ts b/src/config/orm.ts new file mode 100644 index 0000000..5116bad --- /dev/null +++ b/src/config/orm.ts @@ -0,0 +1,20 @@ +import { createConfigLoader } from 'neat-config'; +import { z } from 'zod'; + +export const ormConfigSchema = z.object({ + postgres: z.object({ + // connection URL for postgres database + connection: z.string(), + }), +}); + +export const ormConf = createConfigLoader() + .addFromEnvironment('MWB_') + .addFromCLI('mwb-') + .addFromFile('.env', { + prefix: 'MWB_', + }) + .addFromFile('config.json') + .addZodSchema(ormConfigSchema) + .freeze() + .load(); diff --git a/src/mikro-orm.config.ts b/src/mikro-orm.config.ts index 7ee210d..e27bb97 100644 --- a/src/mikro-orm.config.ts +++ b/src/mikro-orm.config.ts @@ -1,4 +1,4 @@ +import { ormConf } from '@/config/orm'; import { makeOrmConfig } from '@/modules/mikro/orm'; -import { conf } from '@/config'; -export default makeOrmConfig(conf.postgres.connection); +export default makeOrmConfig(ormConf.postgres.connection);