Files
graff-mate-server/src/controllers/commentsController.ts
T
2025-06-09 19:04:42 +05:00

29 lines
763 B
TypeScript

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(
"/",
async ({ auth: { userId }, body: { text, sessionId } }) =>
await createComment({ userId, text, sessionId }),
{
body: t.Object({
text: t.String(),
sessionId: t.String(),
}),
}
);