스킬 정리 및 리팩토링

This commit is contained in:
2026-02-26 09:05:17 +09:00
parent 4c52d6d82f
commit 406af7408a
71 changed files with 3776 additions and 3934 deletions

View File

@@ -1,11 +1,12 @@
import { normalizeTradingEnv, type KisCredentialInput } from "@/lib/kis/config";
import type { NextRequest } from "next/server";
import { z } from "zod";
interface KisCredentialRequestBody {
appKey?: string;
appSecret?: string;
tradingEnv?: string;
}
const kisCredentialRequestBodySchema = z.object({
appKey: z.string().trim().optional(),
appSecret: z.string().trim().optional(),
tradingEnv: z.string().optional(),
});
/**
* @description 요청 본문에서 KIS 인증 정보를 파싱합니다.
@@ -14,14 +15,17 @@ interface KisCredentialRequestBody {
export async function parseKisCredentialRequest(
request: NextRequest,
): Promise<KisCredentialInput> {
let body: KisCredentialRequestBody = {};
let rawBody: unknown = {};
try {
body = (await request.json()) as KisCredentialRequestBody;
rawBody = (await request.json()) as unknown;
} catch {
// 빈 본문 또는 JSON 파싱 실패는 아래 필수값 검증에서 처리합니다.
}
const parsedBody = kisCredentialRequestBodySchema.safeParse(rawBody);
const body = parsedBody.success ? parsedBody.data : {};
return {
appKey: body.appKey?.trim(),
appSecret: body.appSecret?.trim(),