File size: 535 Bytes
c4ae742
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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);
}