Rl-Auto / apps /api /src /queue /store-factory.ts
Lazywords's picture
Deploy RL Auto Docker Space
c4ae742
Raw
History Blame Contribute Delete
535 Bytes
import type { Config } from "../config.js";
import type { Store } from "./store.js";
import { SqliteStore } from "./store.js";
import { PostgresStore } from "./postgres-store.js";
export async function createStore(config: Config): Promise<Store> {
const backend =
config.storeBackend === "postgres" || config.databaseUrl ? "postgres" : "sqlite";
if (backend === "postgres") {
const store = new PostgresStore(config.databaseUrl);
await store.init();
return store;
}
return new SqliteStore(config.sqlitePath);
}