mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-11 23:48:26 +00:00
* feat: Episode ingestion update Benchmarking CORE * Feat: Spaces in knowledge graph * fix: remove daily assignment * Feat: add spaces * Feat: spaces --------- Co-authored-by: Manoj K <saimanoj58@gmail.com>
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import { z } from "zod";
|
|
import { createActionApiRoute } from "~/services/routeBuilders/apiBuilder.server";
|
|
import { SpaceService } from "~/services/space.server";
|
|
import { json } from "@remix-run/node";
|
|
|
|
const spaceService = new SpaceService();
|
|
|
|
// Schema for space ID parameter
|
|
const SpaceParamsSchema = z.object({
|
|
spaceId: z.string(),
|
|
});
|
|
|
|
const { loader } = createActionApiRoute(
|
|
{
|
|
params: SpaceParamsSchema,
|
|
allowJWT: true,
|
|
authorization: {
|
|
action: "search",
|
|
},
|
|
corsStrategy: "all",
|
|
},
|
|
async ({ authentication, params }) => {
|
|
const userId = authentication.userId;
|
|
const { spaceId } = params;
|
|
|
|
// Verify space exists and belongs to user
|
|
const space = await spaceService.getSpace(spaceId, userId);
|
|
if (!space) {
|
|
return json({ error: "Space not found" }, { status: 404 });
|
|
}
|
|
|
|
// Get statements in the space
|
|
const statements = await spaceService.getSpaceStatements(spaceId, userId);
|
|
|
|
return json({
|
|
statements,
|
|
space: {
|
|
uuid: space.uuid,
|
|
name: space.name,
|
|
statementCount: statements.length
|
|
}
|
|
});
|
|
}
|
|
);
|
|
|
|
export { loader }; |