feat: add comments functionality and integrate Socket.io for real-time updates
- Implemented a full comments module in the backend with repository, service, controller, and DTOs using NestJS. - Added frontend support for comments with a `CommentSection` component and integration into content pages. - Introduced `SocketProvider` on the frontend and integrated Socket.io for real-time communication. - Updated dependencies and configurations for Socket.io and WebSockets support.
This commit is contained in:
31
backend/src/database/schemas/comments.ts
Normal file
31
backend/src/database/schemas/comments.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { index, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
|
||||
import { contents } from "./content";
|
||||
import { users } from "./users";
|
||||
|
||||
export const comments = pgTable(
|
||||
"comments",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
contentId: uuid("content_id")
|
||||
.notNull()
|
||||
.references(() => contents.id, { onDelete: "cascade" }),
|
||||
userId: uuid("user_id")
|
||||
.notNull()
|
||||
.references(() => users.uuid, { onDelete: "cascade" }),
|
||||
text: text("text").notNull(),
|
||||
createdAt: timestamp("created_at", { withTimezone: true })
|
||||
.notNull()
|
||||
.defaultNow(),
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true })
|
||||
.notNull()
|
||||
.defaultNow(),
|
||||
deletedAt: timestamp("deleted_at", { withTimezone: true }),
|
||||
},
|
||||
(table) => ({
|
||||
contentIdIdx: index("comments_content_id_idx").on(table.contentId),
|
||||
userIdIdx: index("comments_user_id_idx").on(table.userId),
|
||||
}),
|
||||
);
|
||||
|
||||
export type CommentInDb = typeof comments.$inferSelect;
|
||||
export type NewCommentInDb = typeof comments.$inferInsert;
|
||||
@@ -1,11 +1,13 @@
|
||||
export * from "./api_keys";
|
||||
export * from "./audit_logs";
|
||||
export * from "./categories";
|
||||
export * from "./comments";
|
||||
export * from "./content";
|
||||
export * from "./favorites";
|
||||
export * from "./pgp";
|
||||
export * from "./rbac";
|
||||
export * from "./reports";
|
||||
export * from "./messages";
|
||||
export * from "./sessions";
|
||||
export * from "./tags";
|
||||
export * from "./users";
|
||||
|
||||
Reference in New Issue
Block a user