Add ORM Specific config

This commit is contained in:
William Oldham
2023-11-05 15:12:36 +00:00
parent b1a79242aa
commit ae0ffa9894
2 changed files with 22 additions and 2 deletions

20
src/config/orm.ts Normal file
View File

@@ -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();

View File

@@ -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);