mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor: database connection parsing (#17852)
This commit is contained in:
parent
dab4870fed
commit
1d610ad9cb
13 changed files with 217 additions and 257 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import { Kysely } from 'kysely';
|
||||
import { parse } from 'pg-connection-string';
|
||||
import { DB } from 'src/db';
|
||||
import { ConfigRepository } from 'src/repositories/config.repository';
|
||||
import { DatabaseRepository } from 'src/repositories/database.repository';
|
||||
|
|
@ -37,19 +36,10 @@ const globalSetup = async () => {
|
|||
|
||||
const postgresPort = postgresContainer.getMappedPort(5432);
|
||||
const postgresUrl = `postgres://postgres:postgres@localhost:${postgresPort}/immich`;
|
||||
const parsed = parse(postgresUrl);
|
||||
|
||||
process.env.IMMICH_TEST_POSTGRES_URL = postgresUrl;
|
||||
|
||||
const db = new Kysely<DB>(
|
||||
getKyselyConfig({
|
||||
...parsed,
|
||||
ssl: false,
|
||||
host: parsed.host ?? undefined,
|
||||
port: parsed.port ? Number(parsed.port) : undefined,
|
||||
database: parsed.database ?? undefined,
|
||||
}),
|
||||
);
|
||||
const db = new Kysely<DB>(getKyselyConfig({ connectionType: 'url', url: postgresUrl }));
|
||||
|
||||
const configRepository = new ConfigRepository();
|
||||
const logger = new LoggingRepository(undefined, configRepository);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue