mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-13 04:45:19 +00:00
* hacked together a example of using zoekt grpc api * provide tenant id to zoekt git indexer * update zoekt version to point to multitenant branch * pipe tenant id through header to zoekt * remove incorrect submodule reference and settings typo * update zoekt commit * remove unused yarn script * remove unused grpc client in web server * remove unneeded deps and improve tenant id log * pass tenant id when creating repo in db * add mt yarn script * add nocheckin comment to tenant id in v2 schema --------- Co-authored-by: bkellam <bshizzle1234@gmail.com>
32 lines
No EOL
971 B
TypeScript
32 lines
No EOL
971 B
TypeScript
'use server';
|
|
|
|
import { search } from "@/lib/server/searchService";
|
|
import { searchRequestSchema } from "@/lib/schemas";
|
|
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 tenantId = await request.headers.get("X-Tenant-ID");
|
|
|
|
console.log(`Search request received. Tenant ID: ${tenantId}`);
|
|
|
|
const parsed = await searchRequestSchema.safeParseAsync({
|
|
...body,
|
|
...(tenantId && { tenantId: parseInt(tenantId) }),
|
|
});
|
|
if (!parsed.success) {
|
|
return serviceErrorResponse(
|
|
schemaValidationError(parsed.error)
|
|
);
|
|
}
|
|
|
|
|
|
const response = await search(parsed.data);
|
|
if (isServiceError(response)) {
|
|
return serviceErrorResponse(response);
|
|
}
|
|
|
|
return Response.json(response);
|
|
} |