Files
auto-trade/app/api/kis/domestic/_shared.ts

40 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2026-02-12 14:20:07 +09:00
import { parseKisAccountParts } from "@/lib/kis/account";
import {
normalizeTradingEnv,
type KisCredentialInput,
} from "@/lib/kis/config";
/**
* @description KIS .
* @param headers
* @returns KIS
* @see app/api/kis/domestic/balance/route.ts API
* @see app/api/kis/domestic/indices/route.ts API
*/
export function readKisCredentialsFromHeaders(headers: Headers): KisCredentialInput {
const appKey = headers.get("x-kis-app-key")?.trim();
const appSecret = headers.get("x-kis-app-secret")?.trim();
const tradingEnv = normalizeTradingEnv(
headers.get("x-kis-trading-env") ?? undefined,
);
return {
appKey,
appSecret,
tradingEnv,
};
}
/**
* @description (8-2) .
2026-02-12 14:20:07 +09:00
* @param headers
* @returns (8 + 2) null
* @see app/api/kis/domestic/balance/route.ts
*/
export function readKisAccountParts(headers: Headers) {
const headerAccountNo = headers.get("x-kis-account-no");
const headerAccountProductCode = headers.get("x-kis-account-product-code");
return parseKisAccountParts(headerAccountNo, headerAccountProductCode);
2026-02-12 14:20:07 +09:00
}