251210_01_ENH : 프로젝트 수정, 에디터 구현중
This commit is contained in:
35
src/app/api/intranet/[[...slug]]/route.ts
Normal file
35
src/app/api/intranet/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createContactApi, createIntranetApi} from "@/lib/server-api";
|
||||
import {IntranetProjectSearchResponse, ProjectInfo, ProjectOwnerResponse} from "@/types/project";
|
||||
import {errorToResponse} from "@/lib/http-util";
|
||||
import {ItrntUserInfo} from "@/types/user";
|
||||
|
||||
export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const {slug = []} = await context.params;
|
||||
const [action] = slug;
|
||||
const itrntApi = await createIntranetApi();
|
||||
|
||||
if(action === "project"){
|
||||
const keyword = (searchParams.get("keyword") ?? "").trim();
|
||||
const result = await itrntApi.get<IntranetProjectSearchResponse[]>(
|
||||
`/project/search/top10`,
|
||||
{ query: keyword ? { keyword } : {} }
|
||||
);
|
||||
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if(action === "user-list"){
|
||||
const result = await itrntApi.get<ItrntUserInfo[]>(`/user/list`);
|
||||
|
||||
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