core/apps/webapp/app/routes/api.v1.graph.clustered.tsx
Harshith Mullapudi 1fa7fd93d5
Feat: spaces (#51)
* 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>
2025-08-21 11:53:45 +05:30

44 lines
1.2 KiB
TypeScript

import { json } from "@remix-run/node";
import { logger } from "~/services/logger.service";
import { createHybridLoaderApiRoute } from "~/services/routeBuilders/apiBuilder.server";
import { getClusteredGraphData } from "~/lib/neo4j.server";
import { SpaceService } from "~/services/space.server";
const spaceService = new SpaceService();
const loader = createHybridLoaderApiRoute(
{
allowJWT: true,
corsStrategy: "all",
findResource: async () => 1,
},
async ({ authentication }) => {
try {
// Get clustered graph data and cluster metadata in parallel
const [graphData, clusters] = await Promise.all([
getClusteredGraphData(authentication.userId),
spaceService.getUserSpaces(authentication.userId),
]);
return json({
success: true,
data: {
triplets: graphData,
clusters: clusters,
},
});
} catch (error) {
logger.error("Error in clustered graph loader:", { error });
return json(
{
success: false,
error: error instanceof Error ? error.message : "Unknown error",
},
{ status: 500 },
);
}
},
);
export { loader };