import Elysia, { t } from "elysia"; import authMiddleware from "../middlewares/auth"; import getComments from "../services/comments/getComments"; import { createComment } from "../services/comments/createComment"; export const commentsController = new Elysia({ prefix: "comments" }) .use(authMiddleware) .get( "/:sessionId", async ({ params: { sessionId }, auth: { userId } }) => await getComments(sessionId, userId), { params: t.Object({ sessionId: t.String(), }), } ) .post( "/:sessionId", async ({ params: { sessionId }, auth: { userId }, body: { text } }) => await createComment(sessionId, userId, text), { params: t.Object({ sessionId: t.String(), }), body: t.Object({ text: t.String(), }), } );