core/apps/webapp/app/routes/search.tsx
Harshith Mullapudi 56adc246c8 Feat: UI changes
2025-06-10 12:26:04 +05:30

32 lines
778 B
TypeScript

import { z } from "zod";
import { createActionApiRoute } from "~/services/routeBuilders/apiBuilder.server";
import { SearchService } from "~/services/search.server";
import { json } from "@remix-run/node";
export const SearchBodyRequest = z.object({
query: z.string(),
spaceId: z.string().optional(),
sessionId: z.string().optional(),
});
const searchService = new SearchService();
const { action, loader } = createActionApiRoute(
{
body: SearchBodyRequest,
allowJWT: true,
authorization: {
action: "search",
},
corsStrategy: "all",
},
async ({ body, authentication }) => {
const results = await searchService.search(
body.query,
authentication.userId,
);
return json(results);
},
);
export { action, loader };