Files
graff-mate-server/src/controllers/commentsController.ts
T
2025-06-05 16:46:39 +05:00

31 lines
816 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(
"/: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(),
}),
}
);