260115_02_ENH : 로그인 오류 수정 및 템플릿 생성 연동 완료
This commit is contained in:
23
src/app/api/result-code/[[...slug]]/route.ts
Normal file
23
src/app/api/result-code/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createContactApi} from "@/lib/server-api";
|
||||
import {ProjectInfo, ProjectOwnerResponse, ResultCode} from "@/types/project";
|
||||
import {errorToResponse} from "@/lib/http-util";
|
||||
|
||||
export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const {slug = []} = await context.params;
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if(slug.length === 1){
|
||||
const result = await contactApi.get<ResultCode[]>(`/result-code/${slug[0]}`);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user