feat(config): sélecteur de repository selon DB_IMPL
This commit is contained in:
1 parent
dca234f298
commit
b02f937c96
1 file changed
+13
@@ -0,0 +1,13 @@
|
|||||||
|
import type { CardRepository } from '@/domain/card-repository'
|
||||||
|
import { MongoCardRepository } from '@/repositories/mongo-card-repository'
|
||||||
|
import { MysqlCardRepository } from '@/repositories/mysql-card-repository'
|
||||||
|
|
||||||
|
export type RepositoryImpl = 'mysql' | 'mongo'
|
||||||
|
|
||||||
|
export function getCardRepository(): CardRepository {
|
||||||
|
const impl = (process.env.DB_IMPL ?? 'mysql') as RepositoryImpl
|
||||||
|
if (impl === 'mongo') {
|
||||||
|
return new MongoCardRepository()
|
||||||
|
}
|
||||||
|
return new MysqlCardRepository()
|
||||||
|
}
|
||||||
Reference in new issue
Block a user