upd
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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(),
|
||||
}),
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user