260722_01_ENH: 버그 수정 및 개선 사항 수정
This commit is contained in:
14
src/app/api/external/[[...slug]]/route.ts
vendored
14
src/app/api/external/[[...slug]]/route.ts
vendored
@@ -36,7 +36,7 @@ const toRequiredNumber = (value: string): number | null => {
|
||||
const buildExternalEventBody = (
|
||||
req: NextRequest,
|
||||
action: ExternalAction,
|
||||
prjctIdx: number,
|
||||
prjctSurveyIdx: number,
|
||||
sid: number,
|
||||
): ExternalEventBody => {
|
||||
const pathname = req.nextUrl.pathname;
|
||||
@@ -45,12 +45,12 @@ const buildExternalEventBody = (
|
||||
|
||||
return {
|
||||
action: actionCode,
|
||||
prjctIdx,
|
||||
prjctSurveyIdx,
|
||||
sid,
|
||||
meta: {
|
||||
entryType: getEntryTypeCode(h),
|
||||
action: actionCode,
|
||||
pid: String(prjctIdx),
|
||||
psidx: String(prjctSurveyIdx),
|
||||
sid: String(sid),
|
||||
remoteAddr: getHeader(h, "x-orig-ip") || getClientIp(req),
|
||||
uri: getHeader(h, "x-orig-uri") || pathname,
|
||||
@@ -74,14 +74,14 @@ const handleExternalEvent = async (req: NextRequest, context: RouteContext) => {
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
const prjctIdx = toRequiredNumber((searchParams.get("pid") ?? "").trim());
|
||||
const prjctSurveyIdx = toRequiredNumber((searchParams.get("psidx") ?? "").trim());
|
||||
const sid = toRequiredNumber((searchParams.get("sid") ?? "").trim());
|
||||
|
||||
if (!prjctIdx || !sid) {
|
||||
return NextResponse.json({ message: "pid와 sid는 필수입니다." }, { status: 400 });
|
||||
if (!prjctSurveyIdx || !sid) {
|
||||
return NextResponse.json({ message: "psidx, sid는 필수입니다." }, { status: 400 });
|
||||
}
|
||||
|
||||
const body = buildExternalEventBody(req, action, prjctIdx, sid);
|
||||
const body = buildExternalEventBody(req, action, prjctSurveyIdx, sid);
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
await contactApi.post(`/list-hist/survey`, body);
|
||||
|
||||
Reference in New Issue
Block a user