fixes
This commit is contained in:
@@ -16,15 +16,13 @@ export const commentsController = new Elysia({ prefix: "comments" })
|
||||
}
|
||||
)
|
||||
.post(
|
||||
"/:sessionId",
|
||||
async ({ params: { sessionId }, auth: { userId }, body: { text } }) =>
|
||||
await createComment(sessionId, userId, text),
|
||||
"/",
|
||||
async ({ auth: { userId }, body: { text, sessionId } }) =>
|
||||
await createComment({ userId, text, sessionId }),
|
||||
{
|
||||
params: t.Object({
|
||||
sessionId: t.String(),
|
||||
}),
|
||||
body: t.Object({
|
||||
text: t.String(),
|
||||
sessionId: t.String(),
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { pgTable, serial, text, timestamp, uuid } from "drizzle-orm/pg-core";
|
||||
import { pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
|
||||
import { usersTable } from "./users";
|
||||
import { sessionsTable } from "./sessions";
|
||||
import { relations } from "drizzle-orm";
|
||||
|
||||
export const commentsTable = pgTable("comments", {
|
||||
id: serial("id").primaryKey(),
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
text: text("text").notNull(),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
||||
|
||||
@@ -11,6 +11,7 @@ import db from "./db";
|
||||
import { serversTable } from "./db/schema/servers";
|
||||
import { eq } from "drizzle-orm";
|
||||
import cron from "node-cron";
|
||||
import { commentsController } from "./controllers/commentsController";
|
||||
|
||||
const app = new Elysia();
|
||||
|
||||
@@ -26,6 +27,7 @@ app.use(serversController);
|
||||
app.use(sessionsController);
|
||||
app.use(appsController);
|
||||
app.use(clientsController);
|
||||
app.use(commentsController);
|
||||
|
||||
app.listen(3000);
|
||||
|
||||
|
||||
@@ -2,12 +2,17 @@ import { error } from "elysia";
|
||||
import db from "../../db";
|
||||
import { commentsTable } from "../../db/schema";
|
||||
|
||||
export async function createComment(
|
||||
sessionId: string,
|
||||
userId: string,
|
||||
text: string
|
||||
) {
|
||||
export async function createComment({
|
||||
sessionId,
|
||||
userId,
|
||||
text,
|
||||
}: {
|
||||
sessionId: string;
|
||||
userId: string;
|
||||
text: string;
|
||||
}) {
|
||||
try {
|
||||
console.log(sessionId, userId, text);
|
||||
const comment = await db
|
||||
.insert(commentsTable)
|
||||
.values({
|
||||
|
||||
Reference in New Issue
Block a user