merge: Gateway 데이터베이스 URL 회귀를 바로잡는다

This commit is contained in:
2026-08-22 10:51:38 +00:00
5 changed files with 55 additions and 4 deletions
@@ -0,0 +1,17 @@
import { resolvePostgresConfigFromEnv, type PostgresConfig } from '@sammo-ts/infra';
export const resolveGatewayPostgresConfigFromEnv = (
env: NodeJS.ProcessEnv = process.env,
schema?: string
): PostgresConfig => {
const gatewayDatabaseUrl = env.GATEWAY_DATABASE_URL?.trim();
return resolvePostgresConfigFromEnv({
env: gatewayDatabaseUrl
? {
...env,
DATABASE_URL: gatewayDatabaseUrl,
}
: env,
schema,
});
};
+1
View File
@@ -3,6 +3,7 @@ import { runGatewayOrchestrator } from './orchestrator/orchestratorServer.js';
import { runProfileSeedCli } from './orchestrator/profileSeedCli.js';
export * from './config.js';
export * from './gatewayPostgresConfig.js';
export * from './context.js';
export * from './router.js';
export * from './server.js';
@@ -1,16 +1,16 @@
import {
createGatewayPostgresConnector,
type GatewayPrismaClient,
resolvePostgresConfigFromEnv,
} from '@sammo-ts/infra';
import { resolveGatewayOrchestratorConfigFromEnv } from '../config.js';
import { resolveGatewayPostgresConfigFromEnv } from '../gatewayPostgresConfig.js';
import { createGatewayOrchestrator } from './orchestratorFactory.js';
import { installGatewayShutdownController } from '../lifecycle/shutdownController.js';
export const runGatewayOrchestrator = async (): Promise<void> => {
const config = resolveGatewayOrchestratorConfigFromEnv();
const postgres = createGatewayPostgresConnector(resolvePostgresConfigFromEnv({ schema: config.dbSchema }));
const postgres = createGatewayPostgresConnector(resolveGatewayPostgresConfigFromEnv(process.env, config.dbSchema));
await postgres.connect();
const { orchestrator } = createGatewayOrchestrator(postgres.prisma as GatewayPrismaClient, config, process.env);
+2 -2
View File
@@ -9,11 +9,11 @@ import {
createGatewayPostgresConnector,
createRedisConnector,
type GatewayPrismaClient,
resolvePostgresConfigFromEnv,
resolveRedisConfigFromEnv,
} from '@sammo-ts/infra';
import { resolveGatewayApiConfigFromEnv } from './config.js';
import { resolveGatewayPostgresConfigFromEnv } from './gatewayPostgresConfig.js';
import { createGatewayApiContext } from './context.js';
import { RedisGatewayFlushPublisher } from './auth/flushPublisher.js';
import { KakaoOAuthClient } from './auth/kakaoClient.js';
@@ -36,7 +36,7 @@ import { registerRuntimeNavigationRoute } from './navigation/runtimeNavigationRo
export const createGatewayApiServer = async () => {
const config = resolveGatewayApiConfigFromEnv();
const postgres = createGatewayPostgresConnector(resolvePostgresConfigFromEnv({ schema: config.dbSchema }));
const postgres = createGatewayPostgresConnector(resolveGatewayPostgresConfigFromEnv(process.env, config.dbSchema));
const redis = createRedisConnector(resolveRedisConfigFromEnv());
await postgres.connect();
await redis.connect();
@@ -0,0 +1,33 @@
import { describe, expect, it } from 'vitest';
import { resolveGatewayPostgresConfigFromEnv } from '../src/gatewayPostgresConfig.js';
describe('resolveGatewayPostgresConfigFromEnv', () => {
it('uses the encoded Gateway URL instead of rebuilding one from raw PostgreSQL credentials', () => {
const config = resolveGatewayPostgresConfigFromEnv(
{
GATEWAY_DATABASE_URL: 'postgresql://sammo:encoded%23password@postgres:5432/sammo?schema=legacy',
POSTGRES_USER: 'sammo',
POSTGRES_PASSWORD: 'raw#password',
POSTGRES_HOST: 'postgres',
POSTGRES_PORT: '5432',
POSTGRES_DB: 'sammo',
POSTGRES_POOL_MAX: '4',
},
'public'
);
const parsed = new URL(config.url);
expect(parsed.password).toBe('encoded%23password');
expect(parsed.searchParams.get('schema')).toBe('public');
expect(config.maxConnections).toBe(4);
});
it('keeps DATABASE_URL as the fallback for existing launchers', () => {
const config = resolveGatewayPostgresConfigFromEnv({
DATABASE_URL: 'postgresql://sammo:password@postgres:5432/sammo?schema=public',
});
expect(config.url).toBe('postgresql://sammo:password@postgres:5432/sammo?schema=public');
});
});