MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / GET

Function GET

apps/web/src/app/api/code-indexing/enabled/route.ts:22–53  ·  view source on GitHub ↗
(
  request: NextRequest
)

Source from the content-addressed store, hash-verified

20 * organization path also answers `false` for an unexpected failure, such as a
21 * malformed id.
22 */
23function refusalResponse(error: unknown, organizationPath: boolean): EnabledRouteResponse {
24 if (error instanceof TRPCError && error.cause instanceof StaffRequestRefusal) {
25 return error.cause.response;
26 }
27 if (error instanceof TRPCError || organizationPath) return NextResponse.json({ enabled: false });
28 throw error;
29}
30
31/**
32 * GET /api/code-indexing/enabled?organizationId=<uuid>
33 *
34 * Returns { enabled: true } if:
35 * - organizationId is provided in query params
36 * - User is a member of the organization, or staff the staff guard admits
37 * for a read of it
38 * - Organization has code_indexing_enabled set to true in settings
39 *
40 * Without organizationId, returns whether the personal index is enabled: the
41 * configured list enables it, and a platform admin needs the staff guard.
42 * Both paths reuse this request's one authentication result.
43 *
44 * Returns { enabled: false } otherwise
45 */
46export async function GET(request: NextRequest): Promise<EnabledRouteResponse> {
47 const auth = await getUserFromAuth({ adminOnly: false });
48 if (auth.authFailedResponse) {
49 return auth.authFailedResponse;
50 }
51
52 if (!isCodeIndexingEnabled()) {
53 return NextResponse.json({ enabled: false });
54 }
55
56 const ctx = organizationRestAccessContext(auth, {

Callers

nothing calls this directly

Calls 6

getUserFromAuthFunction · 0.90
isEnabledForUserFunction · 0.90
createTRPCContextFunction · 0.90
getMethod · 0.65
jsonMethod · 0.65

Tested by

no test coverage detected