260728_02_ENH: SID String으로 교체
This commit is contained in:
9
src/app/api/external/[[...slug]]/route.ts
vendored
9
src/app/api/external/[[...slug]]/route.ts
vendored
@@ -33,11 +33,14 @@ const toRequiredNumber = (value: string): number | null => {
|
||||
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : null;
|
||||
};
|
||||
|
||||
const toRequiredSid = (value: string): string | null =>
|
||||
value.length > 0 ? value : null;
|
||||
|
||||
const buildExternalEventBody = (
|
||||
req: NextRequest,
|
||||
action: ExternalAction,
|
||||
prjctSurveyIdx: number,
|
||||
sid: number,
|
||||
sid: string,
|
||||
): ExternalEventBody => {
|
||||
const pathname = req.nextUrl.pathname;
|
||||
const h = req.headers;
|
||||
@@ -51,7 +54,7 @@ const buildExternalEventBody = (
|
||||
entryType: getEntryTypeCode(h),
|
||||
action: actionCode,
|
||||
psidx: String(prjctSurveyIdx),
|
||||
sid: String(sid),
|
||||
sid,
|
||||
remoteAddr: getHeader(h, "x-orig-ip") || getClientIp(req),
|
||||
uri: getHeader(h, "x-orig-uri") || pathname,
|
||||
url: getHeader(h, "x-orig-url") || req.url,
|
||||
@@ -75,7 +78,7 @@ const handleExternalEvent = async (req: NextRequest, context: RouteContext) => {
|
||||
}
|
||||
|
||||
const prjctSurveyIdx = toRequiredNumber((searchParams.get("psidx") ?? "").trim());
|
||||
const sid = toRequiredNumber((searchParams.get("sid") ?? "").trim());
|
||||
const sid = toRequiredSid((searchParams.get("sid") ?? "").trim());
|
||||
|
||||
if (!prjctSurveyIdx || !sid) {
|
||||
return NextResponse.json({ message: "psidx, sid는 필수입니다." }, { status: 400 });
|
||||
|
||||
Reference in New Issue
Block a user