persistance.ts (523B)
1 import { createMemoryPersistance } from "#infrastructure/memory/factory.ts"; 2 import { createPostgresPersistance } from "#infrastructure/postgres/factory.ts"; 3 4 export type PersistanceDependencies = { 5 environment: { 6 PERSISTANCE: "memory" | "postgres"; 7 }; 8 }; 9 10 export function createPersistance( 11 dependencies: PersistanceDependencies, 12 ) { 13 switch (dependencies.environment.PERSISTANCE) { 14 case "memory": 15 return createMemoryPersistance(); 16 case "postgres": 17 return createPostgresPersistance(); 18 } 19 }