mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 04:15:30 +00:00
20 lines
802 B
TypeScript
20 lines
802 B
TypeScript
|
|
import { findSearchBasedSymbolReferences } from "@/features/codeNav/api";
|
||
|
|
import { findRelatedSymbolsRequestSchema } from "@/features/codeNav/types";
|
||
|
|
import { schemaValidationError, serviceErrorResponse } from "@/lib/serviceError";
|
||
|
|
import { isServiceError } from "@/lib/utils";
|
||
|
|
import { NextRequest } from "next/server";
|
||
|
|
|
||
|
|
export const POST = async (request: NextRequest) => {
|
||
|
|
const body = await request.json();
|
||
|
|
const parsed = await findRelatedSymbolsRequestSchema.safeParseAsync(body);
|
||
|
|
if (!parsed.success) {
|
||
|
|
return serviceErrorResponse(schemaValidationError(parsed.error));
|
||
|
|
}
|
||
|
|
|
||
|
|
const response = await findSearchBasedSymbolReferences(parsed.data);
|
||
|
|
if (isServiceError(response)) {
|
||
|
|
return serviceErrorResponse(response);
|
||
|
|
}
|
||
|
|
|
||
|
|
return Response.json(response);
|
||
|
|
}
|