feat: eslint 적용 및 관련 코드 일괄 수정
This commit is contained in:
@@ -1,18 +1,9 @@
|
||||
import { PrismaClient as GamePrismaClient } from '../prisma/generated/game/index.js';
|
||||
export {
|
||||
LogCategory,
|
||||
LogScope,
|
||||
Prisma as GamePrisma,
|
||||
} from '../prisma/generated/game/index.js';
|
||||
export { LogCategory, LogScope, Prisma as GamePrisma } from '../prisma/generated/game/index.js';
|
||||
export type { PrismaClient as GamePrismaClient } from '../prisma/generated/game/index.js';
|
||||
|
||||
import type { PostgresConfig, PostgresConnector } from './postgres.js';
|
||||
import { createPostgresConnector } from './postgres.js';
|
||||
|
||||
export const createGamePostgresConnector = (
|
||||
config: PostgresConfig
|
||||
): PostgresConnector<GamePrismaClient> =>
|
||||
createPostgresConnector(
|
||||
config,
|
||||
(options) => new GamePrismaClient(options)
|
||||
);
|
||||
export const createGamePostgresConnector = (config: PostgresConfig): PostgresConnector<GamePrismaClient> =>
|
||||
createPostgresConnector(config, (options) => new GamePrismaClient(options));
|
||||
|
||||
@@ -10,10 +10,5 @@ export type { PrismaClient as GatewayPrismaClient } from '../prisma/generated/ga
|
||||
import type { PostgresConfig, PostgresConnector } from './postgres.js';
|
||||
import { createPostgresConnector } from './postgres.js';
|
||||
|
||||
export const createGatewayPostgresConnector = (
|
||||
config: PostgresConfig
|
||||
): PostgresConnector<GatewayPrismaClient> =>
|
||||
createPostgresConnector(
|
||||
config,
|
||||
(options) => new GatewayPrismaClient(options)
|
||||
);
|
||||
export const createGatewayPostgresConnector = (config: PostgresConfig): PostgresConnector<GatewayPrismaClient> =>
|
||||
createPostgresConnector(config, (options) => new GatewayPrismaClient(options));
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
export * from './postgres.js';
|
||||
export {
|
||||
createGamePostgresConnector,
|
||||
GamePrisma,
|
||||
LogCategory,
|
||||
LogScope,
|
||||
} from './gamePrisma.js';
|
||||
export { createGamePostgresConnector, GamePrisma, LogCategory, LogScope } from './gamePrisma.js';
|
||||
export type { GamePrismaClient } from './gamePrisma.js';
|
||||
export {
|
||||
createGatewayPostgresConnector,
|
||||
|
||||
@@ -45,10 +45,7 @@ export class LogRepository {
|
||||
constructor(private readonly prisma: GamePrismaClient) {}
|
||||
|
||||
// 전역(시스템) 로그 조회
|
||||
async listSystemLogs(
|
||||
category: LogCategory,
|
||||
options: LogQueryOptions = {}
|
||||
): Promise<LogEntryView[]> {
|
||||
async listSystemLogs(category: LogCategory, options: LogQueryOptions = {}): Promise<LogEntryView[]> {
|
||||
return this.prisma.logEntry.findMany(
|
||||
buildFindArgs(
|
||||
{
|
||||
@@ -97,10 +94,7 @@ export class LogRepository {
|
||||
}
|
||||
|
||||
// 유저 로그 조회
|
||||
async listUserLogs(
|
||||
userId: number,
|
||||
options: LogQueryOptions & { subType?: string } = {}
|
||||
): Promise<LogEntryView[]> {
|
||||
async listUserLogs(userId: number, options: LogQueryOptions & { subType?: string } = {}): Promise<LogEntryView[]> {
|
||||
return this.prisma.logEntry.findMany(
|
||||
buildFindArgs(
|
||||
{
|
||||
|
||||
@@ -26,13 +26,9 @@ export interface PrismaClientFactoryOptions {
|
||||
log?: PostgresLogOption[];
|
||||
}
|
||||
|
||||
export type PrismaClientFactory<TClient> = (
|
||||
options: PrismaClientFactoryOptions
|
||||
) => TClient;
|
||||
export type PrismaClientFactory<TClient> = (options: PrismaClientFactoryOptions) => TClient;
|
||||
|
||||
const resolveSchemaName = (
|
||||
value: string | undefined
|
||||
): string => {
|
||||
const resolveSchemaName = (value: string | undefined): string => {
|
||||
if (!value) {
|
||||
return 'public';
|
||||
}
|
||||
@@ -40,10 +36,7 @@ const resolveSchemaName = (
|
||||
return trimmed ? trimmed : 'public';
|
||||
};
|
||||
|
||||
const applySchemaToDatabaseUrl = (
|
||||
url: string,
|
||||
schema: string | undefined
|
||||
): string => {
|
||||
const applySchemaToDatabaseUrl = (url: string, schema: string | undefined): string => {
|
||||
if (!schema) {
|
||||
return url;
|
||||
}
|
||||
@@ -56,9 +49,7 @@ const applySchemaToDatabaseUrl = (
|
||||
}
|
||||
};
|
||||
|
||||
const extractSchemaFromDatabaseUrl = (
|
||||
url: string
|
||||
): string | undefined => {
|
||||
const extractSchemaFromDatabaseUrl = (url: string): string | undefined => {
|
||||
try {
|
||||
const parsed = new URL(url);
|
||||
const schema = parsed.searchParams.get('schema');
|
||||
@@ -68,18 +59,13 @@ const extractSchemaFromDatabaseUrl = (
|
||||
}
|
||||
};
|
||||
|
||||
const buildDatabaseUrlFromEnv = (
|
||||
env: NodeJS.ProcessEnv,
|
||||
schemaOverride?: string
|
||||
): string => {
|
||||
const buildDatabaseUrlFromEnv = (env: NodeJS.ProcessEnv, schemaOverride?: string): string => {
|
||||
const host = env.POSTGRES_HOST ?? '127.0.0.1';
|
||||
const port = env.POSTGRES_PORT ?? '15432';
|
||||
const user = env.POSTGRES_USER ?? 'sammo';
|
||||
const password = env.POSTGRES_PASSWORD ?? '';
|
||||
const dbName = env.POSTGRES_DB ?? 'sammo';
|
||||
const schema = resolveSchemaName(
|
||||
schemaOverride ?? env.POSTGRES_SCHEMA ?? env.DATABASE_SCHEMA
|
||||
);
|
||||
const schema = resolveSchemaName(schemaOverride ?? env.POSTGRES_SCHEMA ?? env.DATABASE_SCHEMA);
|
||||
return `postgresql://${user}:${password}@${host}:${port}/${dbName}?schema=${schema}`;
|
||||
};
|
||||
|
||||
@@ -102,17 +88,12 @@ export const createPostgresConnector = <TClient>(
|
||||
createClient: PrismaClientFactory<TClient>
|
||||
): PostgresConnector<TClient> => {
|
||||
const schema =
|
||||
extractSchemaFromDatabaseUrl(config.url) ??
|
||||
process.env.POSTGRES_SCHEMA ??
|
||||
process.env.DATABASE_SCHEMA;
|
||||
extractSchemaFromDatabaseUrl(config.url) ?? process.env.POSTGRES_SCHEMA ?? process.env.DATABASE_SCHEMA;
|
||||
const pool = new Pool({
|
||||
connectionString: config.url,
|
||||
...(schema ? { options: `-c search_path=${schema}` } : {}),
|
||||
});
|
||||
const adapter = new PrismaPg(
|
||||
pool,
|
||||
schema ? { schema } : undefined
|
||||
);
|
||||
const adapter = new PrismaPg(pool, schema ? { schema } : undefined);
|
||||
const prisma = createClient({
|
||||
adapter,
|
||||
log: config.log,
|
||||
|
||||
@@ -12,9 +12,7 @@ export interface RedisConnector {
|
||||
disconnect(): Promise<void>;
|
||||
}
|
||||
|
||||
export const resolveRedisConfigFromEnv = (
|
||||
env: NodeJS.ProcessEnv = process.env
|
||||
): RedisConfig => {
|
||||
export const resolveRedisConfigFromEnv = (env: NodeJS.ProcessEnv = process.env): RedisConfig => {
|
||||
const url = env.REDIS_URL ?? '';
|
||||
if (!url) {
|
||||
throw new Error('REDIS_URL is required to create a Redis client.');
|
||||
|
||||
@@ -334,53 +334,31 @@ export interface TurnEngineLogEntryCreateManyInput {
|
||||
export interface TurnEngineDatabaseClient {
|
||||
worldState: {
|
||||
findFirst(args?: unknown): Promise<TurnEngineWorldStateRow | null>;
|
||||
update(args: {
|
||||
where: { id: number };
|
||||
data: TurnEngineWorldStateUpdateInput;
|
||||
}): Promise<unknown>;
|
||||
create(args: {
|
||||
data: TurnEngineWorldStateCreateInput;
|
||||
}): Promise<unknown>;
|
||||
update(args: { where: { id: number }; data: TurnEngineWorldStateUpdateInput }): Promise<unknown>;
|
||||
create(args: { data: TurnEngineWorldStateCreateInput }): Promise<unknown>;
|
||||
deleteMany(args?: unknown): Promise<unknown>;
|
||||
};
|
||||
general: {
|
||||
findMany(args?: unknown): Promise<TurnEngineGeneralRow[]>;
|
||||
createMany(args: {
|
||||
data: TurnEngineGeneralCreateManyInput[];
|
||||
}): Promise<unknown>;
|
||||
update(args: {
|
||||
where: { id: number };
|
||||
data: TurnEngineGeneralUpdateInput;
|
||||
}): Promise<unknown>;
|
||||
createMany(args: { data: TurnEngineGeneralCreateManyInput[] }): Promise<unknown>;
|
||||
update(args: { where: { id: number }; data: TurnEngineGeneralUpdateInput }): Promise<unknown>;
|
||||
deleteMany(args?: unknown): Promise<unknown>;
|
||||
};
|
||||
city: {
|
||||
findMany(args?: unknown): Promise<TurnEngineCityRow[]>;
|
||||
createMany(args: {
|
||||
data: TurnEngineCityCreateManyInput[];
|
||||
}): Promise<unknown>;
|
||||
update(args: {
|
||||
where: { id: number };
|
||||
data: TurnEngineCityUpdateInput;
|
||||
}): Promise<unknown>;
|
||||
createMany(args: { data: TurnEngineCityCreateManyInput[] }): Promise<unknown>;
|
||||
update(args: { where: { id: number }; data: TurnEngineCityUpdateInput }): Promise<unknown>;
|
||||
deleteMany(args?: unknown): Promise<unknown>;
|
||||
};
|
||||
nation: {
|
||||
findMany(args?: unknown): Promise<TurnEngineNationRow[]>;
|
||||
createMany(args: {
|
||||
data: TurnEngineNationCreateManyInput[];
|
||||
}): Promise<unknown>;
|
||||
update(args: {
|
||||
where: { id: number };
|
||||
data: TurnEngineNationUpdateInput;
|
||||
}): Promise<unknown>;
|
||||
createMany(args: { data: TurnEngineNationCreateManyInput[] }): Promise<unknown>;
|
||||
update(args: { where: { id: number }; data: TurnEngineNationUpdateInput }): Promise<unknown>;
|
||||
deleteMany(args?: unknown): Promise<unknown>;
|
||||
};
|
||||
diplomacy: {
|
||||
findMany(args?: unknown): Promise<TurnEngineDiplomacyRow[]>;
|
||||
createMany(args: {
|
||||
data: TurnEngineDiplomacyCreateManyInput[];
|
||||
}): Promise<unknown>;
|
||||
createMany(args: { data: TurnEngineDiplomacyCreateManyInput[] }): Promise<unknown>;
|
||||
update(args: {
|
||||
where: {
|
||||
srcNationId_destNationId: {
|
||||
@@ -394,26 +372,17 @@ export interface TurnEngineDatabaseClient {
|
||||
};
|
||||
troop: {
|
||||
findMany(args?: unknown): Promise<TurnEngineTroopRow[]>;
|
||||
createMany(args: {
|
||||
data: TurnEngineTroopCreateManyInput[];
|
||||
}): Promise<unknown>;
|
||||
update(args: {
|
||||
where: { troopLeaderId: number };
|
||||
data: TurnEngineTroopUpdateInput;
|
||||
}): Promise<unknown>;
|
||||
createMany(args: { data: TurnEngineTroopCreateManyInput[] }): Promise<unknown>;
|
||||
update(args: { where: { troopLeaderId: number }; data: TurnEngineTroopUpdateInput }): Promise<unknown>;
|
||||
deleteMany(args?: unknown): Promise<unknown>;
|
||||
};
|
||||
event: {
|
||||
findMany(args?: unknown): Promise<TurnEngineEventRow[]>;
|
||||
createMany(args: {
|
||||
data: TurnEngineEventCreateManyInput[];
|
||||
}): Promise<unknown>;
|
||||
createMany(args: { data: TurnEngineEventCreateManyInput[] }): Promise<unknown>;
|
||||
deleteMany(args?: unknown): Promise<unknown>;
|
||||
};
|
||||
logEntry: {
|
||||
createMany(args: {
|
||||
data: TurnEngineLogEntryCreateManyInput[];
|
||||
}): Promise<unknown>;
|
||||
createMany(args: { data: TurnEngineLogEntryCreateManyInput[] }): Promise<unknown>;
|
||||
};
|
||||
generalTurn: {
|
||||
findMany(args?: unknown): Promise<TurnEngineGeneralTurnRow[]>;
|
||||
|
||||
Reference in New Issue
Block a user