Skip to content

Commit 0260cc4

Browse files
committed
feat: Refactor repository exception handling and introduce bookmarks feature
- Renamed RepositoryException to ActionException for clarity and consistency. - Updated all service files to use the new ActionException for error handling. - Introduced bookmarks functionality with a new bookmarks table and related service actions. - Added input validation for bookmark actions. - Updated session actions to use authID instead of getSessionUserId for better clarity. - Cleaned up article and user profile update inputs to allow optional fields. - Created migration for the new bookmarks table and related schema changes.
1 parent 32a9173 commit 0260cc4

File tree

76 files changed

+926
-15345
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+926
-15345
lines changed

drizzle.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import "dotenv/config";
21
import { defineConfig } from "drizzle-kit";
32
import * as process from "node:process";
43
import dotenv from "dotenv";
@@ -9,7 +8,7 @@ dotenv.config({
98

109
export default defineConfig({
1110
out: "./migrations",
12-
schema: "./src/backend/persistence/schema.ts",
11+
schema: "./src/backend/persistence/schemas.ts",
1312
dialect: "postgresql",
1413
dbCredentials: {
1514
url: process.env.DATABASE_URL!,
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
CREATE TABLE "article_tag" (
2+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
3+
"article_id" uuid NOT NULL,
4+
"tag_id" uuid NOT NULL,
5+
"created_at" timestamp,
6+
"updated_at" timestamp
7+
);
8+
--> statement-breakpoint
9+
CREATE TABLE "articles" (
10+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
11+
"title" varchar NOT NULL,
12+
"handle" varchar NOT NULL,
13+
"excerpt" varchar,
14+
"body" text,
15+
"cover_image" jsonb,
16+
"is_published" boolean DEFAULT false,
17+
"published_at" timestamp,
18+
"approved_at" timestamp,
19+
"metadata" jsonb,
20+
"author_id" uuid NOT NULL,
21+
"created_at" timestamp,
22+
"updated_at" timestamp
23+
);
24+
--> statement-breakpoint
25+
CREATE TABLE "bookmarks" (
26+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
27+
"user_id" uuid NOT NULL,
28+
"resource_id" uuid NOT NULL,
29+
"resource_type" varchar(50) NOT NULL,
30+
"created_at" timestamp,
31+
"updated_at" timestamp
32+
);
33+
--> statement-breakpoint
34+
CREATE TABLE "comments" (
35+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
36+
"body" text NOT NULL,
37+
"commentable_type" varchar NOT NULL,
38+
"commentable_id" uuid NOT NULL,
39+
"user_id" uuid NOT NULL,
40+
"parent_id" uuid,
41+
"created_at" timestamp DEFAULT now(),
42+
"updated_at" timestamp DEFAULT now()
43+
);
44+
--> statement-breakpoint
45+
CREATE TABLE "series_items" (
46+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
47+
"series_id" uuid NOT NULL,
48+
"type" varchar NOT NULL,
49+
"title" varchar,
50+
"article_id" uuid,
51+
"index" integer DEFAULT 0 NOT NULL,
52+
"created_at" timestamp,
53+
"updated_at" timestamp
54+
);
55+
--> statement-breakpoint
56+
CREATE TABLE "series" (
57+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
58+
"title" varchar NOT NULL,
59+
"handle" varchar,
60+
"cover_image" jsonb,
61+
"owner_id" uuid NOT NULL,
62+
"created_at" timestamp,
63+
"updated_at" timestamp
64+
);
65+
--> statement-breakpoint
66+
CREATE TABLE "tags" (
67+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
68+
"name" varchar(50) NOT NULL,
69+
"icon" jsonb,
70+
"color" varchar(6),
71+
"description" text,
72+
"created_at" timestamp,
73+
"updated_at" timestamp
74+
);
75+
--> statement-breakpoint
76+
CREATE TABLE "user_follows" (
77+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
78+
"follower_id" uuid NOT NULL,
79+
"followee_id" uuid NOT NULL,
80+
"created_at" timestamp,
81+
"updated_at" timestamp
82+
);
83+
--> statement-breakpoint
84+
CREATE TABLE "user_sessions" (
85+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
86+
"user_id" uuid NOT NULL,
87+
"token" varchar NOT NULL,
88+
"device" varchar,
89+
"ip" varchar,
90+
"last_action_at" timestamp,
91+
"created_at" timestamp,
92+
"updated_at" timestamp
93+
);
94+
--> statement-breakpoint
95+
CREATE TABLE "user_socials" (
96+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
97+
"service" varchar NOT NULL,
98+
"service_uid" varchar NOT NULL,
99+
"user_id" uuid NOT NULL,
100+
"created_at" timestamp,
101+
"updated_at" timestamp
102+
);
103+
--> statement-breakpoint
104+
CREATE TABLE "users" (
105+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
106+
"name" varchar NOT NULL,
107+
"username" varchar NOT NULL,
108+
"email" varchar,
109+
"profile_photo" varchar,
110+
"education" varchar,
111+
"designation" varchar,
112+
"bio" varchar,
113+
"website_url" varchar,
114+
"location" varchar,
115+
"social_links" json,
116+
"profile_readme" text,
117+
"skills" varchar,
118+
"created_at" timestamp,
119+
"updated_at" timestamp
120+
);
121+
--> statement-breakpoint
122+
ALTER TABLE "article_tag" ADD CONSTRAINT "article_tag_article_id_articles_id_fk" FOREIGN KEY ("article_id") REFERENCES "public"."articles"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
123+
ALTER TABLE "article_tag" ADD CONSTRAINT "article_tag_tag_id_tags_id_fk" FOREIGN KEY ("tag_id") REFERENCES "public"."tags"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
124+
ALTER TABLE "articles" ADD CONSTRAINT "articles_author_id_users_id_fk" FOREIGN KEY ("author_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
125+
ALTER TABLE "bookmarks" ADD CONSTRAINT "bookmarks_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
126+
ALTER TABLE "comments" ADD CONSTRAINT "comments_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
127+
ALTER TABLE "comments" ADD CONSTRAINT "comments_parent_id_comments_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."comments"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
128+
ALTER TABLE "series_items" ADD CONSTRAINT "series_items_series_id_series_id_fk" FOREIGN KEY ("series_id") REFERENCES "public"."series"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
129+
ALTER TABLE "series_items" ADD CONSTRAINT "series_items_article_id_articles_id_fk" FOREIGN KEY ("article_id") REFERENCES "public"."articles"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
130+
ALTER TABLE "series" ADD CONSTRAINT "series_owner_id_users_id_fk" FOREIGN KEY ("owner_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
131+
ALTER TABLE "user_follows" ADD CONSTRAINT "user_follows_follower_id_users_id_fk" FOREIGN KEY ("follower_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
132+
ALTER TABLE "user_follows" ADD CONSTRAINT "user_follows_followee_id_users_id_fk" FOREIGN KEY ("followee_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
133+
ALTER TABLE "user_sessions" ADD CONSTRAINT "user_sessions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
134+
ALTER TABLE "user_socials" ADD CONSTRAINT "user_socials_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;

migrations/0000_real_nomad.sql

Lines changed: 0 additions & 28 deletions
This file was deleted.

migrations/0001_useful_husk.sql

Lines changed: 0 additions & 8 deletions
This file was deleted.

migrations/0002_wakeful_dorian_gray.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

migrations/0003_certain_corsair.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

migrations/0004_normal_skrulls.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

migrations/0005_noisy_stark_industries.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

migrations/0006_greedy_greymalkin.sql

Lines changed: 0 additions & 25 deletions
This file was deleted.

migrations/0007_clear_polaris.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)