261007_01_ENH: 메시지 API contact-back 경유 전환, 발송 경로 변경 및 발신 이메일 형식 검증 추가

This commit is contained in:
2026-10-07 11:24:24 +09:00
parent d088661719
commit f12c374a84
11 changed files with 44 additions and 51 deletions

View File

@@ -1,6 +1,6 @@
import {NextRequest, NextResponse} from "next/server";
import {RouteContext} from "@/types/common";
import {createNotihubApi} from "@/lib/http-server";
import {createContactApi} from "@/lib/http-server";
import {errorToResponse} from "@kri/common/http";
import type {FileResponse, PageRequest, PageResponse} from "@kri/common";
import type {BulkSendInfo, SendResultSummaryRequest, SendResultSummaryResponse} from "@kri/common/noti-hub";
@@ -10,11 +10,11 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
try {
const {slug = []} = await context.params;
const [action, sendTy, reqstSvc, prjctCd] = slug;
const notihubApi = await createNotihubApi();
const contactApi = await createContactApi();
if (action === "bulk-list" && sendTy && reqstSvc && prjctCd) {
const result = await notihubApi.get<BulkSendInfo[]>(
`/report/bulk-list/${sendTy}/${reqstSvc}/${prjctCd}`,
const result = await contactApi.get<BulkSendInfo[]>(
`/message-report/bulk-list/${sendTy}/${reqstSvc}/${prjctCd}`,
);
return NextResponse.json(result, {status: 200});
}
@@ -23,8 +23,8 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
const [, sid, prjctCdParam, reqstSvcParam] = slug;
const channelTy = req.nextUrl.searchParams.get("channelTy");
const query = channelTy ? `?channelTy=${channelTy}` : "";
const result = await notihubApi.get<SendResultInfo[]>(
`/report/send-result/${encodeURIComponent(sid)}/${prjctCdParam}/${reqstSvcParam}${query}`,
const result = await contactApi.get<SendResultInfo[]>(
`/message-report/send-result/${encodeURIComponent(sid)}/${prjctCdParam}/${reqstSvcParam}${query}`,
);
return NextResponse.json(result, {status: 200});
}
@@ -39,7 +39,7 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
try {
const {slug = []} = await context.params;
const [action, bulkSendKey] = slug;
const notihubApi = await createNotihubApi();
const contactApi = await createContactApi();
if (action === "bulk-detail" && bulkSendKey) {
const body: PageRequest | null = await req.json().catch(() => null);
@@ -47,16 +47,16 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
return NextResponse.json({message: "요청 바디가 없습니다."}, {status: 400});
}
const result = await notihubApi.post<PageResponse<SendResultInfo>>(
`/report/bulk-detail/${bulkSendKey}`,
const result = await contactApi.post<PageResponse<SendResultInfo>>(
`/message-report/bulk-detail/${bulkSendKey}`,
body,
);
return NextResponse.json(result, {status: 200});
}
if (action === "bulk-detail-excel" && bulkSendKey) {
const result = await notihubApi.post<FileResponse>(
`/report/bulk-detail/excel/${bulkSendKey}`,
const result = await contactApi.post<FileResponse>(
`/message-report/bulk-detail-excel/${bulkSendKey}`,
undefined,
);
return NextResponse.json(result, {status: 200});
@@ -68,8 +68,8 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
return NextResponse.json({message: "요청 바디가 없습니다."}, {status: 400});
}
const result = await notihubApi.post<SendResultSummaryResponse[]>(
`/report/send-result-summary`,
const result = await contactApi.post<SendResultSummaryResponse[]>(
`/message-report/send-result-summary`,
body,
);
return NextResponse.json(result, {status: 200});

View File

@@ -22,12 +22,12 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
}
if (action === "single") {
const result = await contactApi.post<SendSingleResponse>(`/message/${channel}/single/${prjctIdx}`, body);
const result = await contactApi.post<SendSingleResponse>(`/message-send/${channel}/single/${prjctIdx}`, body);
return NextResponse.json(result, {status: 200});
}
if (action === "bulk") {
const result = await contactApi.post<MessageBulkSendResponse>(`/message/${channel}/bulk/${prjctIdx}`, body);
const result = await contactApi.post<MessageBulkSendResponse>(`/message-send/${channel}/bulk/${prjctIdx}`, body);
return NextResponse.json(result, {status: 200});
}

View File

@@ -1,6 +1,6 @@
import {NextRequest, NextResponse} from "next/server";
import {RouteContext} from "@/types/common";
import {createNotihubApi} from "@/lib/http-server";
import {createContactApi} from "@/lib/http-server";
import {errorToResponse} from "@kri/common/http";
import type { Template, TemplateSummary } from "@kri/common/noti-hub";
@@ -9,7 +9,7 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
const { searchParams } = new URL(req.url);
const {slug = []} = await context.params;
const [action] = slug;
const notihubApi = await createNotihubApi();
const contactApi = await createContactApi();
if(slug.length === 2 && slug[1] === "attachment"){
const fileName = searchParams.get("fileName");
@@ -17,23 +17,23 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
return NextResponse.json({ message: "fileName은 필수입니다." }, { status: 400 });
}
const result = await notihubApi.get<ArrayBuffer>(
`/template/${slug[0]}/attachment?fileName=${encodeURIComponent(fileName)}`,
const result = await contactApi.get<ArrayBuffer>(
`/message-template/${slug[0]}/attachment?fileName=${encodeURIComponent(fileName)}`,
{ expectBinary: true },
);
return new NextResponse(result, { status: 200, headers: { "Content-Type": "application/octet-stream" } });
}
if(slug.length === 1){
const result = await notihubApi.get<Template>(
`/template/${slug[0]}`,
const result = await contactApi.get<Template>(
`/message-template/${slug[0]}`,
);
return NextResponse.json(result, { status: 200 });
}
if(action === "list" && slug.length === 3){
const result = await notihubApi.get<TemplateSummary[]>(
`/template/list/${slug[1]}/${slug[2]}`,
const result = await contactApi.get<TemplateSummary[]>(
`/message-template/list/${slug[1]}/${slug[2]}`,
);
return NextResponse.json(result, { status: 200 });
}
@@ -49,7 +49,7 @@ export const PUT = async (req: NextRequest, context: RouteContext) => {
const { searchParams } = new URL(req.url);
const {slug = []} = await context.params;
const [action] = slug;
const notihubApi = await createNotihubApi();
const contactApi = await createContactApi();
if(action === "body-image" && slug.length === 2){
const itrntPrjctCd = slug[1];
@@ -64,8 +64,8 @@ export const PUT = async (req: NextRequest, context: RouteContext) => {
);
}
const result = await notihubApi.putForm<string>(
`/template/body-image/${itrntPrjctCd}`,
const result = await contactApi.putForm<string>(
`/message-template/body-image/${itrntPrjctCd}`,
formData
);
@@ -81,7 +81,7 @@ export const PUT = async (req: NextRequest, context: RouteContext) => {
);
}
const result = await notihubApi.putForm<Template>(`/template`, formData);
const result = await contactApi.putForm<Template>(`/message-template`, formData);
return NextResponse.json(result, { status: 200 });
}
@@ -96,7 +96,7 @@ export const PATCH = async (req: NextRequest, context: RouteContext) => {
const { searchParams } = new URL(req.url);
const {slug = []} = await context.params;
const [action] = slug;
const notihubApi = await createNotihubApi();
const contactApi = await createContactApi();
if(!action){
const formData = await req.formData().catch(() => null);
@@ -107,7 +107,7 @@ export const PATCH = async (req: NextRequest, context: RouteContext) => {
);
}
const result = await notihubApi.request<Template>(`/template`, { method: "PATCH", form: formData });
const result = await contactApi.request<Template>(`/message-template`, { method: "PATCH", form: formData });
return NextResponse.json(result, { status: 200 });
}