core/apps/webapp/app/routes/api.v1.spaces.$spaceId.episodes.ts
Harshith Mullapudi bcc0560cf0
Feat: Space (#93)
* Feat: change space assignment from statement to episode

* feat: add default spaces and improve integration, space tools discovery in MCP

* feat: change spaces to episode based

* Feat: take multiple spaceIds while ingesting

* Feat: modify mcp tool descriptions, add spaceId in mcp url

* feat: add copy

* bump: new version 0.1.24

---------

Co-authored-by: Manoj <saimanoj58@gmail.com>
2025-10-09 12:38:42 +05:30

50 lines
1.3 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";
import { getSpaceEpisodeCount } from "~/services/graphModels/space";
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 episodes in the space
const episodes = await spaceService.getSpaceEpisodes(spaceId, userId);
const episodeCount = await getSpaceEpisodeCount(spaceId, userId);
return json({
episodes,
space: {
uuid: space.uuid,
name: space.name,
description: space.description,
episodeCount,
}
});
}
);
export { loader };