From 45a49e3f2f77f499335943ddb940889abab686a0 Mon Sep 17 00:00:00 2001 From: Face <69168154+face-hh@users.noreply.github.com> Date: Wed, 25 Jun 2025 22:33:07 +0300 Subject: [PATCH] feat: api --- ..._bloodstrike.sql => 0000_chief_korath.sql} | 54 +- website/drizzle/0001_cuddly_dormammu.sql | 1 - website/drizzle/0002_small_micromacro.sql | 1 - website/drizzle/0003_complete_runaways.sql | 19 - website/drizzle/meta/0000_snapshot.json | 502 +++- website/drizzle/meta/0001_snapshot.json | 1720 -------------- website/drizzle/meta/0002_snapshot.json | 1727 -------------- website/drizzle/meta/0003_snapshot.json | 2027 ----------------- website/drizzle/meta/_journal.json | 25 +- website/src/lib/auth.ts | 16 + .../src/lib/components/self/AppSidebar.svelte | 28 +- .../src/lib/components/self/Codeblock.svelte | 47 + .../ui/collapsible/collapsible-content.svelte | 7 + .../ui/collapsible/collapsible-trigger.svelte | 7 + .../ui/collapsible/collapsible.svelte | 11 + .../lib/components/ui/collapsible/index.ts | 13 + website/src/lib/server/api-auth.ts | 20 + website/src/lib/server/db/schema.ts | 28 +- website/src/routes/api/+page.server.ts | 20 + website/src/routes/api/+page.svelte | 650 ++++++ website/src/routes/api/keys/+server.ts | 51 + website/src/routes/api/keys/[id]/+server.ts | 49 + .../api/keys/[id]/regenerate/+server.ts | 62 + .../api/v1/coin/[coinSymbol]/+server.ts | 8 + .../api/v1/holders/[coinSymbol]/+server.ts | 8 + website/src/routes/api/v1/hopium/+server.ts | 19 + .../src/routes/api/v1/hopium/[id]/+server.ts | 20 + website/src/routes/api/v1/market/+server.ts | 7 + website/src/routes/api/v1/top/+server.ts | 7 + 29 files changed, 1622 insertions(+), 5532 deletions(-) rename website/drizzle/{0000_crazy_bloodstrike.sql => 0000_chief_korath.sql} (82%) delete mode 100644 website/drizzle/0001_cuddly_dormammu.sql delete mode 100644 website/drizzle/0002_small_micromacro.sql delete mode 100644 website/drizzle/0003_complete_runaways.sql delete mode 100644 website/drizzle/meta/0001_snapshot.json delete mode 100644 website/drizzle/meta/0002_snapshot.json delete mode 100644 website/drizzle/meta/0003_snapshot.json create mode 100644 website/src/lib/components/self/Codeblock.svelte create mode 100644 website/src/lib/components/ui/collapsible/collapsible-content.svelte create mode 100644 website/src/lib/components/ui/collapsible/collapsible-trigger.svelte create mode 100644 website/src/lib/components/ui/collapsible/collapsible.svelte create mode 100644 website/src/lib/components/ui/collapsible/index.ts create mode 100644 website/src/lib/server/api-auth.ts create mode 100644 website/src/routes/api/+page.server.ts create mode 100644 website/src/routes/api/+page.svelte create mode 100644 website/src/routes/api/keys/+server.ts create mode 100644 website/src/routes/api/keys/[id]/+server.ts create mode 100644 website/src/routes/api/keys/[id]/regenerate/+server.ts create mode 100644 website/src/routes/api/v1/coin/[coinSymbol]/+server.ts create mode 100644 website/src/routes/api/v1/holders/[coinSymbol]/+server.ts create mode 100644 website/src/routes/api/v1/hopium/+server.ts create mode 100644 website/src/routes/api/v1/hopium/[id]/+server.ts create mode 100644 website/src/routes/api/v1/market/+server.ts create mode 100644 website/src/routes/api/v1/top/+server.ts diff --git a/website/drizzle/0000_crazy_bloodstrike.sql b/website/drizzle/0000_chief_korath.sql similarity index 82% rename from website/drizzle/0000_crazy_bloodstrike.sql rename to website/drizzle/0000_chief_korath.sql index f7e2008..ea92912 100644 --- a/website/drizzle/0000_crazy_bloodstrike.sql +++ b/website/drizzle/0000_chief_korath.sql @@ -42,6 +42,30 @@ CREATE TABLE IF NOT EXISTS "account_deletion_request" ( CONSTRAINT "account_deletion_request_user_id_unique" UNIQUE("user_id") ); --> statement-breakpoint +CREATE TABLE IF NOT EXISTS "apikey" ( + "id" serial PRIMARY KEY NOT NULL, + "name" text, + "start" text, + "prefix" text, + "key" text NOT NULL, + "user_id" integer NOT NULL, + "refill_interval" integer, + "refill_amount" integer, + "last_refill_at" timestamp, + "enabled" boolean, + "rate_limit_enabled" boolean, + "rate_limit_time_window" integer, + "rate_limit_max" integer, + "request_count" integer, + "remaining" integer, + "last_request" timestamp, + "expires_at" timestamp, + "created_at" timestamp NOT NULL, + "updated_at" timestamp NOT NULL, + "permissions" text, + "metadata" text +); +--> statement-breakpoint CREATE TABLE IF NOT EXISTS "coin" ( "id" serial PRIMARY KEY NOT NULL, "name" varchar(255) NOT NULL, @@ -189,6 +213,7 @@ CREATE TABLE IF NOT EXISTS "user" ( "last_reward_claim" timestamp with time zone, "total_rewards_claimed" numeric(20, 8) DEFAULT '0.00000000' NOT NULL, "login_streak" integer DEFAULT 0 NOT NULL, + "prestige_level" integer DEFAULT 0, CONSTRAINT "user_email_unique" UNIQUE("email"), CONSTRAINT "user_username_unique" UNIQUE("username") ); @@ -222,6 +247,12 @@ EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "apikey" ADD CONSTRAINT "apikey_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint DO $$ BEGIN ALTER TABLE "coin" ADD CONSTRAINT "coin_creator_id_user_id_fk" FOREIGN KEY ("creator_id") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action; EXCEPTION @@ -345,6 +376,15 @@ END $$; CREATE INDEX IF NOT EXISTS "account_deletion_request_user_id_idx" ON "account_deletion_request" USING btree ("user_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "account_deletion_request_scheduled_deletion_idx" ON "account_deletion_request" USING btree ("scheduled_deletion_at");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "account_deletion_request_open_idx" ON "account_deletion_request" USING btree ("user_id") WHERE is_processed = false;--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "idx_apikey_user" ON "apikey" USING btree ("user_id");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "coin_symbol_idx" ON "coin" USING btree ("symbol");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "coin_creator_id_idx" ON "coin" USING btree ("creator_id");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "coin_is_listed_idx" ON "coin" USING btree ("is_listed");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "coin_market_cap_idx" ON "coin" USING btree ("market_cap");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "coin_current_price_idx" ON "coin" USING btree ("current_price");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "coin_change24h_idx" ON "coin" USING btree ("change_24h");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "coin_volume24h_idx" ON "coin" USING btree ("volume_24h");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "coin_created_at_idx" ON "coin" USING btree ("created_at");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "comment_user_id_idx" ON "comment" USING btree ("user_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "comment_coin_id_idx" ON "comment" USING btree ("coin_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "notification_user_id_idx" ON "notification" USING btree ("user_id");--> statement-breakpoint @@ -357,4 +397,16 @@ CREATE INDEX IF NOT EXISTS "prediction_bet_user_question_idx" ON "prediction_bet CREATE INDEX IF NOT EXISTS "prediction_bet_created_at_idx" ON "prediction_bet" USING btree ("created_at");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "prediction_question_creator_id_idx" ON "prediction_question" USING btree ("creator_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "prediction_question_status_idx" ON "prediction_question" USING btree ("status");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "prediction_question_resolution_date_idx" ON "prediction_question" USING btree ("resolution_date"); \ No newline at end of file +CREATE INDEX IF NOT EXISTS "prediction_question_resolution_date_idx" ON "prediction_question" USING btree ("resolution_date");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "prediction_question_status_resolution_idx" ON "prediction_question" USING btree ("status","resolution_date");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "transaction_user_id_idx" ON "transaction" USING btree ("user_id");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "transaction_coin_id_idx" ON "transaction" USING btree ("coin_id");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "transaction_type_idx" ON "transaction" USING btree ("type");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "transaction_timestamp_idx" ON "transaction" USING btree ("timestamp");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "transaction_user_coin_idx" ON "transaction" USING btree ("user_id","coin_id");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "transaction_coin_type_idx" ON "transaction" USING btree ("coin_id","type");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "user_username_idx" ON "user" USING btree ("username");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "user_is_banned_idx" ON "user" USING btree ("is_banned");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "user_is_admin_idx" ON "user" USING btree ("is_admin");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "user_created_at_idx" ON "user" USING btree ("created_at");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "user_updated_at_idx" ON "user" USING btree ("updated_at"); \ No newline at end of file diff --git a/website/drizzle/0001_cuddly_dormammu.sql b/website/drizzle/0001_cuddly_dormammu.sql deleted file mode 100644 index c1828c0..0000000 --- a/website/drizzle/0001_cuddly_dormammu.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE INDEX IF NOT EXISTS "prediction_question_status_resolution_idx" ON "prediction_question" USING btree ("status","resolution_date"); \ No newline at end of file diff --git a/website/drizzle/0002_small_micromacro.sql b/website/drizzle/0002_small_micromacro.sql deleted file mode 100644 index 5488a04..0000000 --- a/website/drizzle/0002_small_micromacro.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "user" ADD COLUMN "prestige_level" integer DEFAULT 0; \ No newline at end of file diff --git a/website/drizzle/0003_complete_runaways.sql b/website/drizzle/0003_complete_runaways.sql deleted file mode 100644 index a7b2e52..0000000 --- a/website/drizzle/0003_complete_runaways.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE INDEX IF NOT EXISTS "coin_symbol_idx" ON "coin" USING btree ("symbol");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "coin_creator_id_idx" ON "coin" USING btree ("creator_id");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "coin_is_listed_idx" ON "coin" USING btree ("is_listed");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "coin_market_cap_idx" ON "coin" USING btree ("market_cap");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "coin_current_price_idx" ON "coin" USING btree ("current_price");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "coin_change24h_idx" ON "coin" USING btree ("change_24h");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "coin_volume24h_idx" ON "coin" USING btree ("volume_24h");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "coin_created_at_idx" ON "coin" USING btree ("created_at");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "transaction_user_id_idx" ON "transaction" USING btree ("user_id");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "transaction_coin_id_idx" ON "transaction" USING btree ("coin_id");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "transaction_type_idx" ON "transaction" USING btree ("type");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "transaction_timestamp_idx" ON "transaction" USING btree ("timestamp");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "transaction_user_coin_idx" ON "transaction" USING btree ("user_id","coin_id");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "transaction_coin_type_idx" ON "transaction" USING btree ("coin_id","type");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "user_username_idx" ON "user" USING btree ("username");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "user_is_banned_idx" ON "user" USING btree ("is_banned");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "user_is_admin_idx" ON "user" USING btree ("is_admin");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "user_created_at_idx" ON "user" USING btree ("created_at");--> statement-breakpoint -CREATE INDEX IF NOT EXISTS "user_updated_at_idx" ON "user" USING btree ("updated_at"); \ No newline at end of file diff --git a/website/drizzle/meta/0000_snapshot.json b/website/drizzle/meta/0000_snapshot.json index e66aff3..3e919aa 100644 --- a/website/drizzle/meta/0000_snapshot.json +++ b/website/drizzle/meta/0000_snapshot.json @@ -1,5 +1,5 @@ { - "id": "41f7bba3-1d5d-41ba-83bb-ca129ace81f0", + "id": "08d1623b-7b2d-4777-8b7b-dbfa7884ecfe", "prevId": "00000000-0000-0000-0000-000000000000", "version": "7", "dialect": "postgresql", @@ -225,6 +225,172 @@ } } }, + "public.apikey": { + "name": "apikey", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "start": { + "name": "start", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prefix": { + "name": "prefix", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "refill_interval": { + "name": "refill_interval", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "refill_amount": { + "name": "refill_amount", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "last_refill_at": { + "name": "last_refill_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "rate_limit_enabled": { + "name": "rate_limit_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "rate_limit_time_window": { + "name": "rate_limit_time_window", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "rate_limit_max": { + "name": "rate_limit_max", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "request_count": { + "name": "request_count", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "remaining": { + "name": "remaining", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "last_request": { + "name": "last_request", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "permissions": { + "name": "permissions", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_apikey_user": { + "name": "idx_apikey_user", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "apikey_user_id_user_id_fk": { + "name": "apikey_user_id_user_id_fk", + "tableFrom": "apikey", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, "public.coin": { "name": "coin", "schema": "", @@ -333,7 +499,128 @@ "default": true } }, - "indexes": {}, + "indexes": { + "coin_symbol_idx": { + "name": "coin_symbol_idx", + "columns": [ + { + "expression": "symbol", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "coin_creator_id_idx": { + "name": "coin_creator_id_idx", + "columns": [ + { + "expression": "creator_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "coin_is_listed_idx": { + "name": "coin_is_listed_idx", + "columns": [ + { + "expression": "is_listed", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "coin_market_cap_idx": { + "name": "coin_market_cap_idx", + "columns": [ + { + "expression": "market_cap", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "coin_current_price_idx": { + "name": "coin_current_price_idx", + "columns": [ + { + "expression": "current_price", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "coin_change24h_idx": { + "name": "coin_change24h_idx", + "columns": [ + { + "expression": "change_24h", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "coin_volume24h_idx": { + "name": "coin_volume24h_idx", + "columns": [ + { + "expression": "volume_24h", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "coin_created_at_idx": { + "name": "coin_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, "foreignKeys": { "coin_creator_id_user_id_fk": { "name": "coin_creator_id_user_id_fk", @@ -955,6 +1242,27 @@ "concurrently": false, "method": "btree", "with": {} + }, + "prediction_question_status_resolution_idx": { + "name": "prediction_question_status_resolution_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "resolution_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} } }, "foreignKeys": { @@ -1338,7 +1646,110 @@ "notNull": false } }, - "indexes": {}, + "indexes": { + "transaction_user_id_idx": { + "name": "transaction_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "transaction_coin_id_idx": { + "name": "transaction_coin_id_idx", + "columns": [ + { + "expression": "coin_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "transaction_type_idx": { + "name": "transaction_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "transaction_timestamp_idx": { + "name": "transaction_timestamp_idx", + "columns": [ + { + "expression": "timestamp", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "transaction_user_coin_idx": { + "name": "transaction_user_coin_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "coin_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "transaction_coin_type_idx": { + "name": "transaction_coin_type_idx", + "columns": [ + { + "expression": "coin_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, "foreignKeys": { "transaction_user_id_user_id_fk": { "name": "transaction_user_id_user_id_fk", @@ -1518,9 +1929,92 @@ "primaryKey": false, "notNull": true, "default": 0 + }, + "prestige_level": { + "name": "prestige_level", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + } + }, + "indexes": { + "user_username_idx": { + "name": "user_username_idx", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_is_banned_idx": { + "name": "user_is_banned_idx", + "columns": [ + { + "expression": "is_banned", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_is_admin_idx": { + "name": "user_is_admin_idx", + "columns": [ + { + "expression": "is_admin", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_created_at_idx": { + "name": "user_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_updated_at_idx": { + "name": "user_updated_at_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} } }, - "indexes": {}, "foreignKeys": {}, "compositePrimaryKeys": {}, "uniqueConstraints": { diff --git a/website/drizzle/meta/0001_snapshot.json b/website/drizzle/meta/0001_snapshot.json deleted file mode 100644 index ceac887..0000000 --- a/website/drizzle/meta/0001_snapshot.json +++ /dev/null @@ -1,1720 +0,0 @@ -{ - "id": "3eec8d9d-b3cd-4af8-8cde-73c38bd840e7", - "prevId": "41f7bba3-1d5d-41ba-83bb-ca129ace81f0", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.account": { - "name": "account", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "account_id": { - "name": "account_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider_id": { - "name": "provider_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "access_token": { - "name": "access_token", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "refresh_token": { - "name": "refresh_token", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "id_token": { - "name": "id_token", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "access_token_expires_at": { - "name": "access_token_expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "refresh_token_expires_at": { - "name": "refresh_token_expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "scope": { - "name": "scope", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "account_user_id_user_id_fk": { - "name": "account_user_id_user_id_fk", - "tableFrom": "account", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.account_deletion_request": { - "name": "account_deletion_request", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "requested_at": { - "name": "requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "scheduled_deletion_at": { - "name": "scheduled_deletion_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "reason": { - "name": "reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_processed": { - "name": "is_processed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - } - }, - "indexes": { - "account_deletion_request_user_id_idx": { - "name": "account_deletion_request_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "account_deletion_request_scheduled_deletion_idx": { - "name": "account_deletion_request_scheduled_deletion_idx", - "columns": [ - { - "expression": "scheduled_deletion_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "account_deletion_request_open_idx": { - "name": "account_deletion_request_open_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "is_processed = false", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "account_deletion_request_user_id_user_id_fk": { - "name": "account_deletion_request_user_id_user_id_fk", - "tableFrom": "account_deletion_request", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "account_deletion_request_user_id_unique": { - "name": "account_deletion_request_user_id_unique", - "nullsNotDistinct": false, - "columns": [ - "user_id" - ] - } - } - }, - "public.coin": { - "name": "coin", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "symbol": { - "name": "symbol", - "type": "varchar(10)", - "primaryKey": false, - "notNull": true - }, - "icon": { - "name": "icon", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "creator_id": { - "name": "creator_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "initial_supply": { - "name": "initial_supply", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true - }, - "circulating_supply": { - "name": "circulating_supply", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true - }, - "current_price": { - "name": "current_price", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "market_cap": { - "name": "market_cap", - "type": "numeric(30, 2)", - "primaryKey": false, - "notNull": true - }, - "volume_24h": { - "name": "volume_24h", - "type": "numeric(30, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.00'" - }, - "change_24h": { - "name": "change_24h", - "type": "numeric(30, 4)", - "primaryKey": false, - "notNull": false, - "default": "'0.0000'" - }, - "pool_coin_amount": { - "name": "pool_coin_amount", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true, - "default": "'0.00000000'" - }, - "pool_base_currency_amount": { - "name": "pool_base_currency_amount", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true, - "default": "'0.00000000'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "is_listed": { - "name": "is_listed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - } - }, - "indexes": {}, - "foreignKeys": { - "coin_creator_id_user_id_fk": { - "name": "coin_creator_id_user_id_fk", - "tableFrom": "coin", - "tableTo": "user", - "columnsFrom": [ - "creator_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "coin_symbol_unique": { - "name": "coin_symbol_unique", - "nullsNotDistinct": false, - "columns": [ - "symbol" - ] - } - } - }, - "public.comment": { - "name": "comment", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "coin_id": { - "name": "coin_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "varchar(500)", - "primaryKey": false, - "notNull": true - }, - "likes_count": { - "name": "likes_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "is_deleted": { - "name": "is_deleted", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - } - }, - "indexes": { - "comment_user_id_idx": { - "name": "comment_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "comment_coin_id_idx": { - "name": "comment_coin_id_idx", - "columns": [ - { - "expression": "coin_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "comment_user_id_user_id_fk": { - "name": "comment_user_id_user_id_fk", - "tableFrom": "comment", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "comment_coin_id_coin_id_fk": { - "name": "comment_coin_id_coin_id_fk", - "tableFrom": "comment", - "tableTo": "coin", - "columnsFrom": [ - "coin_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.comment_like": { - "name": "comment_like", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "comment_id": { - "name": "comment_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "comment_like_user_id_user_id_fk": { - "name": "comment_like_user_id_user_id_fk", - "tableFrom": "comment_like", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "comment_like_comment_id_comment_id_fk": { - "name": "comment_like_comment_id_comment_id_fk", - "tableFrom": "comment_like", - "tableTo": "comment", - "columnsFrom": [ - "comment_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "comment_like_user_id_comment_id_pk": { - "name": "comment_like_user_id_comment_id_pk", - "columns": [ - "user_id", - "comment_id" - ] - } - }, - "uniqueConstraints": {} - }, - "public.notification": { - "name": "notification", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "notification_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "varchar(200)", - "primaryKey": false, - "notNull": true - }, - "message": { - "name": "message", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_read": { - "name": "is_read", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "notification_user_id_idx": { - "name": "notification_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "notification_type_idx": { - "name": "notification_type_idx", - "columns": [ - { - "expression": "type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "notification_is_read_idx": { - "name": "notification_is_read_idx", - "columns": [ - { - "expression": "is_read", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "notification_created_at_idx": { - "name": "notification_created_at_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "notification_user_id_user_id_fk": { - "name": "notification_user_id_user_id_fk", - "tableFrom": "notification", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.prediction_bet": { - "name": "prediction_bet", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "question_id": { - "name": "question_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "side": { - "name": "side", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "amount": { - "name": "amount", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "actual_winnings": { - "name": "actual_winnings", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "settled_at": { - "name": "settled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "prediction_bet_user_id_idx": { - "name": "prediction_bet_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_bet_question_id_idx": { - "name": "prediction_bet_question_id_idx", - "columns": [ - { - "expression": "question_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_bet_user_question_idx": { - "name": "prediction_bet_user_question_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "question_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_bet_created_at_idx": { - "name": "prediction_bet_created_at_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "prediction_bet_user_id_user_id_fk": { - "name": "prediction_bet_user_id_user_id_fk", - "tableFrom": "prediction_bet", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "prediction_bet_question_id_prediction_question_id_fk": { - "name": "prediction_bet_question_id_prediction_question_id_fk", - "tableFrom": "prediction_bet", - "tableTo": "prediction_question", - "columnsFrom": [ - "question_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.prediction_question": { - "name": "prediction_question", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "creator_id": { - "name": "creator_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "question": { - "name": "question", - "type": "varchar(200)", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "prediction_market_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'ACTIVE'" - }, - "resolution_date": { - "name": "resolution_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "ai_resolution": { - "name": "ai_resolution", - "type": "boolean", - "primaryKey": false, - "notNull": false - }, - "total_yes_amount": { - "name": "total_yes_amount", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true, - "default": "'0.00000000'" - }, - "total_no_amount": { - "name": "total_no_amount", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true, - "default": "'0.00000000'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "resolved_at": { - "name": "resolved_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "requires_web_search": { - "name": "requires_web_search", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "validation_reason": { - "name": "validation_reason", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "prediction_question_creator_id_idx": { - "name": "prediction_question_creator_id_idx", - "columns": [ - { - "expression": "creator_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_question_status_idx": { - "name": "prediction_question_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_question_resolution_date_idx": { - "name": "prediction_question_resolution_date_idx", - "columns": [ - { - "expression": "resolution_date", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_question_status_resolution_idx": { - "name": "prediction_question_status_resolution_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resolution_date", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "prediction_question_creator_id_user_id_fk": { - "name": "prediction_question_creator_id_user_id_fk", - "tableFrom": "prediction_question", - "tableTo": "user", - "columnsFrom": [ - "creator_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.price_history": { - "name": "price_history", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "coin_id": { - "name": "coin_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "timestamp": { - "name": "timestamp", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "price_history_coin_id_coin_id_fk": { - "name": "price_history_coin_id_coin_id_fk", - "tableFrom": "price_history", - "tableTo": "coin", - "columnsFrom": [ - "coin_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.promo_code": { - "name": "promo_code", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "code": { - "name": "code", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reward_amount": { - "name": "reward_amount", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "max_uses": { - "name": "max_uses", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_by": { - "name": "created_by", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "promo_code_created_by_user_id_fk": { - "name": "promo_code_created_by_user_id_fk", - "tableFrom": "promo_code", - "tableTo": "user", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "promo_code_code_unique": { - "name": "promo_code_code_unique", - "nullsNotDistinct": false, - "columns": [ - "code" - ] - } - } - }, - "public.promo_code_redemption": { - "name": "promo_code_redemption", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "promo_code_id": { - "name": "promo_code_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "reward_amount": { - "name": "reward_amount", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "redeemed_at": { - "name": "redeemed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "promo_code_redemption_user_id_user_id_fk": { - "name": "promo_code_redemption_user_id_user_id_fk", - "tableFrom": "promo_code_redemption", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "promo_code_redemption_promo_code_id_promo_code_id_fk": { - "name": "promo_code_redemption_promo_code_id_promo_code_id_fk", - "tableFrom": "promo_code_redemption", - "tableTo": "promo_code", - "columnsFrom": [ - "promo_code_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "promo_code_redemption_user_id_promo_code_id_unique": { - "name": "promo_code_redemption_user_id_promo_code_id_unique", - "nullsNotDistinct": false, - "columns": [ - "user_id", - "promo_code_id" - ] - } - } - }, - "public.session": { - "name": "session", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "token": { - "name": "token", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "ip_address": { - "name": "ip_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "session_user_id_user_id_fk": { - "name": "session_user_id_user_id_fk", - "tableFrom": "session", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "session_token_unique": { - "name": "session_token_unique", - "nullsNotDistinct": false, - "columns": [ - "token" - ] - } - } - }, - "public.transaction": { - "name": "transaction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "coin_id": { - "name": "coin_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "transaction_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "quantity": { - "name": "quantity", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true - }, - "price_per_coin": { - "name": "price_per_coin", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "total_base_currency_amount": { - "name": "total_base_currency_amount", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true - }, - "timestamp": { - "name": "timestamp", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "recipient_user_id": { - "name": "recipient_user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "sender_user_id": { - "name": "sender_user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "transaction_user_id_user_id_fk": { - "name": "transaction_user_id_user_id_fk", - "tableFrom": "transaction", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "transaction_coin_id_coin_id_fk": { - "name": "transaction_coin_id_coin_id_fk", - "tableFrom": "transaction", - "tableTo": "coin", - "columnsFrom": [ - "coin_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "transaction_recipient_user_id_user_id_fk": { - "name": "transaction_recipient_user_id_user_id_fk", - "tableFrom": "transaction", - "tableTo": "user", - "columnsFrom": [ - "recipient_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "transaction_sender_user_id_user_id_fk": { - "name": "transaction_sender_user_id_user_id_fk", - "tableFrom": "transaction", - "tableTo": "user", - "columnsFrom": [ - "sender_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email_verified": { - "name": "email_verified", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "is_admin": { - "name": "is_admin", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "is_banned": { - "name": "is_banned", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "ban_reason": { - "name": "ban_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "base_currency_balance": { - "name": "base_currency_balance", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true, - "default": "'100.00000000'" - }, - "bio": { - "name": "bio", - "type": "varchar(160)", - "primaryKey": false, - "notNull": false, - "default": "'Hello am 48 year old man from somalia. Sorry for my bed england. I selled my wife for internet connection for play “conter stirk”'" - }, - "username": { - "name": "username", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true - }, - "volume_master": { - "name": "volume_master", - "type": "numeric(3, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.70'" - }, - "volume_muted": { - "name": "volume_muted", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "last_reward_claim": { - "name": "last_reward_claim", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "total_rewards_claimed": { - "name": "total_rewards_claimed", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true, - "default": "'0.00000000'" - }, - "login_streak": { - "name": "login_streak", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - }, - "user_username_unique": { - "name": "user_username_unique", - "nullsNotDistinct": false, - "columns": [ - "username" - ] - } - } - }, - "public.user_portfolio": { - "name": "user_portfolio", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "coin_id": { - "name": "coin_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "quantity": { - "name": "quantity", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "user_portfolio_user_id_user_id_fk": { - "name": "user_portfolio_user_id_user_id_fk", - "tableFrom": "user_portfolio", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_portfolio_coin_id_coin_id_fk": { - "name": "user_portfolio_coin_id_coin_id_fk", - "tableFrom": "user_portfolio", - "tableTo": "coin", - "columnsFrom": [ - "coin_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "user_portfolio_user_id_coin_id_pk": { - "name": "user_portfolio_user_id_coin_id_pk", - "columns": [ - "user_id", - "coin_id" - ] - } - }, - "uniqueConstraints": {} - }, - "public.verification": { - "name": "verification", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "identifier": { - "name": "identifier", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "value": { - "name": "value", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": { - "public.notification_type": { - "name": "notification_type", - "schema": "public", - "values": [ - "HOPIUM", - "SYSTEM", - "TRANSFER", - "RUG_PULL" - ] - }, - "public.prediction_market_status": { - "name": "prediction_market_status", - "schema": "public", - "values": [ - "ACTIVE", - "RESOLVED", - "CANCELLED" - ] - }, - "public.transaction_type": { - "name": "transaction_type", - "schema": "public", - "values": [ - "BUY", - "SELL", - "TRANSFER_IN", - "TRANSFER_OUT" - ] - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/website/drizzle/meta/0002_snapshot.json b/website/drizzle/meta/0002_snapshot.json deleted file mode 100644 index 9c38fdd..0000000 --- a/website/drizzle/meta/0002_snapshot.json +++ /dev/null @@ -1,1727 +0,0 @@ -{ - "id": "223d9abc-f0d3-4c71-9cda-8a069fc13205", - "prevId": "3eec8d9d-b3cd-4af8-8cde-73c38bd840e7", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.account": { - "name": "account", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "account_id": { - "name": "account_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider_id": { - "name": "provider_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "access_token": { - "name": "access_token", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "refresh_token": { - "name": "refresh_token", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "id_token": { - "name": "id_token", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "access_token_expires_at": { - "name": "access_token_expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "refresh_token_expires_at": { - "name": "refresh_token_expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "scope": { - "name": "scope", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "account_user_id_user_id_fk": { - "name": "account_user_id_user_id_fk", - "tableFrom": "account", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.account_deletion_request": { - "name": "account_deletion_request", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "requested_at": { - "name": "requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "scheduled_deletion_at": { - "name": "scheduled_deletion_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "reason": { - "name": "reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_processed": { - "name": "is_processed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - } - }, - "indexes": { - "account_deletion_request_user_id_idx": { - "name": "account_deletion_request_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "account_deletion_request_scheduled_deletion_idx": { - "name": "account_deletion_request_scheduled_deletion_idx", - "columns": [ - { - "expression": "scheduled_deletion_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "account_deletion_request_open_idx": { - "name": "account_deletion_request_open_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "is_processed = false", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "account_deletion_request_user_id_user_id_fk": { - "name": "account_deletion_request_user_id_user_id_fk", - "tableFrom": "account_deletion_request", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "account_deletion_request_user_id_unique": { - "name": "account_deletion_request_user_id_unique", - "nullsNotDistinct": false, - "columns": [ - "user_id" - ] - } - } - }, - "public.coin": { - "name": "coin", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "symbol": { - "name": "symbol", - "type": "varchar(10)", - "primaryKey": false, - "notNull": true - }, - "icon": { - "name": "icon", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "creator_id": { - "name": "creator_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "initial_supply": { - "name": "initial_supply", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true - }, - "circulating_supply": { - "name": "circulating_supply", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true - }, - "current_price": { - "name": "current_price", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "market_cap": { - "name": "market_cap", - "type": "numeric(30, 2)", - "primaryKey": false, - "notNull": true - }, - "volume_24h": { - "name": "volume_24h", - "type": "numeric(30, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.00'" - }, - "change_24h": { - "name": "change_24h", - "type": "numeric(30, 4)", - "primaryKey": false, - "notNull": false, - "default": "'0.0000'" - }, - "pool_coin_amount": { - "name": "pool_coin_amount", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true, - "default": "'0.00000000'" - }, - "pool_base_currency_amount": { - "name": "pool_base_currency_amount", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true, - "default": "'0.00000000'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "is_listed": { - "name": "is_listed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - } - }, - "indexes": {}, - "foreignKeys": { - "coin_creator_id_user_id_fk": { - "name": "coin_creator_id_user_id_fk", - "tableFrom": "coin", - "tableTo": "user", - "columnsFrom": [ - "creator_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "coin_symbol_unique": { - "name": "coin_symbol_unique", - "nullsNotDistinct": false, - "columns": [ - "symbol" - ] - } - } - }, - "public.comment": { - "name": "comment", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "coin_id": { - "name": "coin_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "varchar(500)", - "primaryKey": false, - "notNull": true - }, - "likes_count": { - "name": "likes_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "is_deleted": { - "name": "is_deleted", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - } - }, - "indexes": { - "comment_user_id_idx": { - "name": "comment_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "comment_coin_id_idx": { - "name": "comment_coin_id_idx", - "columns": [ - { - "expression": "coin_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "comment_user_id_user_id_fk": { - "name": "comment_user_id_user_id_fk", - "tableFrom": "comment", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "comment_coin_id_coin_id_fk": { - "name": "comment_coin_id_coin_id_fk", - "tableFrom": "comment", - "tableTo": "coin", - "columnsFrom": [ - "coin_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.comment_like": { - "name": "comment_like", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "comment_id": { - "name": "comment_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "comment_like_user_id_user_id_fk": { - "name": "comment_like_user_id_user_id_fk", - "tableFrom": "comment_like", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "comment_like_comment_id_comment_id_fk": { - "name": "comment_like_comment_id_comment_id_fk", - "tableFrom": "comment_like", - "tableTo": "comment", - "columnsFrom": [ - "comment_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "comment_like_user_id_comment_id_pk": { - "name": "comment_like_user_id_comment_id_pk", - "columns": [ - "user_id", - "comment_id" - ] - } - }, - "uniqueConstraints": {} - }, - "public.notification": { - "name": "notification", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "notification_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "varchar(200)", - "primaryKey": false, - "notNull": true - }, - "message": { - "name": "message", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_read": { - "name": "is_read", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "notification_user_id_idx": { - "name": "notification_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "notification_type_idx": { - "name": "notification_type_idx", - "columns": [ - { - "expression": "type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "notification_is_read_idx": { - "name": "notification_is_read_idx", - "columns": [ - { - "expression": "is_read", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "notification_created_at_idx": { - "name": "notification_created_at_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "notification_user_id_user_id_fk": { - "name": "notification_user_id_user_id_fk", - "tableFrom": "notification", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.prediction_bet": { - "name": "prediction_bet", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "question_id": { - "name": "question_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "side": { - "name": "side", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "amount": { - "name": "amount", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "actual_winnings": { - "name": "actual_winnings", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "settled_at": { - "name": "settled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "prediction_bet_user_id_idx": { - "name": "prediction_bet_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_bet_question_id_idx": { - "name": "prediction_bet_question_id_idx", - "columns": [ - { - "expression": "question_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_bet_user_question_idx": { - "name": "prediction_bet_user_question_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "question_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_bet_created_at_idx": { - "name": "prediction_bet_created_at_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "prediction_bet_user_id_user_id_fk": { - "name": "prediction_bet_user_id_user_id_fk", - "tableFrom": "prediction_bet", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "prediction_bet_question_id_prediction_question_id_fk": { - "name": "prediction_bet_question_id_prediction_question_id_fk", - "tableFrom": "prediction_bet", - "tableTo": "prediction_question", - "columnsFrom": [ - "question_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.prediction_question": { - "name": "prediction_question", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "creator_id": { - "name": "creator_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "question": { - "name": "question", - "type": "varchar(200)", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "prediction_market_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'ACTIVE'" - }, - "resolution_date": { - "name": "resolution_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "ai_resolution": { - "name": "ai_resolution", - "type": "boolean", - "primaryKey": false, - "notNull": false - }, - "total_yes_amount": { - "name": "total_yes_amount", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true, - "default": "'0.00000000'" - }, - "total_no_amount": { - "name": "total_no_amount", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true, - "default": "'0.00000000'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "resolved_at": { - "name": "resolved_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "requires_web_search": { - "name": "requires_web_search", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "validation_reason": { - "name": "validation_reason", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "prediction_question_creator_id_idx": { - "name": "prediction_question_creator_id_idx", - "columns": [ - { - "expression": "creator_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_question_status_idx": { - "name": "prediction_question_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_question_resolution_date_idx": { - "name": "prediction_question_resolution_date_idx", - "columns": [ - { - "expression": "resolution_date", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_question_status_resolution_idx": { - "name": "prediction_question_status_resolution_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resolution_date", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "prediction_question_creator_id_user_id_fk": { - "name": "prediction_question_creator_id_user_id_fk", - "tableFrom": "prediction_question", - "tableTo": "user", - "columnsFrom": [ - "creator_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.price_history": { - "name": "price_history", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "coin_id": { - "name": "coin_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "timestamp": { - "name": "timestamp", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "price_history_coin_id_coin_id_fk": { - "name": "price_history_coin_id_coin_id_fk", - "tableFrom": "price_history", - "tableTo": "coin", - "columnsFrom": [ - "coin_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.promo_code": { - "name": "promo_code", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "code": { - "name": "code", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reward_amount": { - "name": "reward_amount", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "max_uses": { - "name": "max_uses", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_by": { - "name": "created_by", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "promo_code_created_by_user_id_fk": { - "name": "promo_code_created_by_user_id_fk", - "tableFrom": "promo_code", - "tableTo": "user", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "promo_code_code_unique": { - "name": "promo_code_code_unique", - "nullsNotDistinct": false, - "columns": [ - "code" - ] - } - } - }, - "public.promo_code_redemption": { - "name": "promo_code_redemption", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "promo_code_id": { - "name": "promo_code_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "reward_amount": { - "name": "reward_amount", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "redeemed_at": { - "name": "redeemed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "promo_code_redemption_user_id_user_id_fk": { - "name": "promo_code_redemption_user_id_user_id_fk", - "tableFrom": "promo_code_redemption", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "promo_code_redemption_promo_code_id_promo_code_id_fk": { - "name": "promo_code_redemption_promo_code_id_promo_code_id_fk", - "tableFrom": "promo_code_redemption", - "tableTo": "promo_code", - "columnsFrom": [ - "promo_code_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "promo_code_redemption_user_id_promo_code_id_unique": { - "name": "promo_code_redemption_user_id_promo_code_id_unique", - "nullsNotDistinct": false, - "columns": [ - "user_id", - "promo_code_id" - ] - } - } - }, - "public.session": { - "name": "session", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "token": { - "name": "token", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "ip_address": { - "name": "ip_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "session_user_id_user_id_fk": { - "name": "session_user_id_user_id_fk", - "tableFrom": "session", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "session_token_unique": { - "name": "session_token_unique", - "nullsNotDistinct": false, - "columns": [ - "token" - ] - } - } - }, - "public.transaction": { - "name": "transaction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "coin_id": { - "name": "coin_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "transaction_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "quantity": { - "name": "quantity", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true - }, - "price_per_coin": { - "name": "price_per_coin", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "total_base_currency_amount": { - "name": "total_base_currency_amount", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true - }, - "timestamp": { - "name": "timestamp", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "recipient_user_id": { - "name": "recipient_user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "sender_user_id": { - "name": "sender_user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "transaction_user_id_user_id_fk": { - "name": "transaction_user_id_user_id_fk", - "tableFrom": "transaction", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "transaction_coin_id_coin_id_fk": { - "name": "transaction_coin_id_coin_id_fk", - "tableFrom": "transaction", - "tableTo": "coin", - "columnsFrom": [ - "coin_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "transaction_recipient_user_id_user_id_fk": { - "name": "transaction_recipient_user_id_user_id_fk", - "tableFrom": "transaction", - "tableTo": "user", - "columnsFrom": [ - "recipient_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "transaction_sender_user_id_user_id_fk": { - "name": "transaction_sender_user_id_user_id_fk", - "tableFrom": "transaction", - "tableTo": "user", - "columnsFrom": [ - "sender_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email_verified": { - "name": "email_verified", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "is_admin": { - "name": "is_admin", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "is_banned": { - "name": "is_banned", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "ban_reason": { - "name": "ban_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "base_currency_balance": { - "name": "base_currency_balance", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true, - "default": "'100.00000000'" - }, - "bio": { - "name": "bio", - "type": "varchar(160)", - "primaryKey": false, - "notNull": false, - "default": "'Hello am 48 year old man from somalia. Sorry for my bed england. I selled my wife for internet connection for play “conter stirk”'" - }, - "username": { - "name": "username", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true - }, - "volume_master": { - "name": "volume_master", - "type": "numeric(3, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.70'" - }, - "volume_muted": { - "name": "volume_muted", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "last_reward_claim": { - "name": "last_reward_claim", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "total_rewards_claimed": { - "name": "total_rewards_claimed", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true, - "default": "'0.00000000'" - }, - "login_streak": { - "name": "login_streak", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "prestige_level": { - "name": "prestige_level", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - }, - "user_username_unique": { - "name": "user_username_unique", - "nullsNotDistinct": false, - "columns": [ - "username" - ] - } - } - }, - "public.user_portfolio": { - "name": "user_portfolio", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "coin_id": { - "name": "coin_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "quantity": { - "name": "quantity", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "user_portfolio_user_id_user_id_fk": { - "name": "user_portfolio_user_id_user_id_fk", - "tableFrom": "user_portfolio", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_portfolio_coin_id_coin_id_fk": { - "name": "user_portfolio_coin_id_coin_id_fk", - "tableFrom": "user_portfolio", - "tableTo": "coin", - "columnsFrom": [ - "coin_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "user_portfolio_user_id_coin_id_pk": { - "name": "user_portfolio_user_id_coin_id_pk", - "columns": [ - "user_id", - "coin_id" - ] - } - }, - "uniqueConstraints": {} - }, - "public.verification": { - "name": "verification", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "identifier": { - "name": "identifier", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "value": { - "name": "value", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": { - "public.notification_type": { - "name": "notification_type", - "schema": "public", - "values": [ - "HOPIUM", - "SYSTEM", - "TRANSFER", - "RUG_PULL" - ] - }, - "public.prediction_market_status": { - "name": "prediction_market_status", - "schema": "public", - "values": [ - "ACTIVE", - "RESOLVED", - "CANCELLED" - ] - }, - "public.transaction_type": { - "name": "transaction_type", - "schema": "public", - "values": [ - "BUY", - "SELL", - "TRANSFER_IN", - "TRANSFER_OUT" - ] - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/website/drizzle/meta/0003_snapshot.json b/website/drizzle/meta/0003_snapshot.json deleted file mode 100644 index 7abf363..0000000 --- a/website/drizzle/meta/0003_snapshot.json +++ /dev/null @@ -1,2027 +0,0 @@ -{ - "id": "496c23a1-1fd7-4116-b72d-5b56db3e7059", - "prevId": "223d9abc-f0d3-4c71-9cda-8a069fc13205", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.account": { - "name": "account", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "account_id": { - "name": "account_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider_id": { - "name": "provider_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "access_token": { - "name": "access_token", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "refresh_token": { - "name": "refresh_token", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "id_token": { - "name": "id_token", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "access_token_expires_at": { - "name": "access_token_expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "refresh_token_expires_at": { - "name": "refresh_token_expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "scope": { - "name": "scope", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "account_user_id_user_id_fk": { - "name": "account_user_id_user_id_fk", - "tableFrom": "account", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.account_deletion_request": { - "name": "account_deletion_request", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "requested_at": { - "name": "requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "scheduled_deletion_at": { - "name": "scheduled_deletion_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "reason": { - "name": "reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_processed": { - "name": "is_processed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - } - }, - "indexes": { - "account_deletion_request_user_id_idx": { - "name": "account_deletion_request_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "account_deletion_request_scheduled_deletion_idx": { - "name": "account_deletion_request_scheduled_deletion_idx", - "columns": [ - { - "expression": "scheduled_deletion_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "account_deletion_request_open_idx": { - "name": "account_deletion_request_open_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "is_processed = false", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "account_deletion_request_user_id_user_id_fk": { - "name": "account_deletion_request_user_id_user_id_fk", - "tableFrom": "account_deletion_request", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "account_deletion_request_user_id_unique": { - "name": "account_deletion_request_user_id_unique", - "nullsNotDistinct": false, - "columns": [ - "user_id" - ] - } - } - }, - "public.coin": { - "name": "coin", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "symbol": { - "name": "symbol", - "type": "varchar(10)", - "primaryKey": false, - "notNull": true - }, - "icon": { - "name": "icon", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "creator_id": { - "name": "creator_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "initial_supply": { - "name": "initial_supply", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true - }, - "circulating_supply": { - "name": "circulating_supply", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true - }, - "current_price": { - "name": "current_price", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "market_cap": { - "name": "market_cap", - "type": "numeric(30, 2)", - "primaryKey": false, - "notNull": true - }, - "volume_24h": { - "name": "volume_24h", - "type": "numeric(30, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.00'" - }, - "change_24h": { - "name": "change_24h", - "type": "numeric(30, 4)", - "primaryKey": false, - "notNull": false, - "default": "'0.0000'" - }, - "pool_coin_amount": { - "name": "pool_coin_amount", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true, - "default": "'0.00000000'" - }, - "pool_base_currency_amount": { - "name": "pool_base_currency_amount", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true, - "default": "'0.00000000'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "is_listed": { - "name": "is_listed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - } - }, - "indexes": { - "coin_symbol_idx": { - "name": "coin_symbol_idx", - "columns": [ - { - "expression": "symbol", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "coin_creator_id_idx": { - "name": "coin_creator_id_idx", - "columns": [ - { - "expression": "creator_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "coin_is_listed_idx": { - "name": "coin_is_listed_idx", - "columns": [ - { - "expression": "is_listed", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "coin_market_cap_idx": { - "name": "coin_market_cap_idx", - "columns": [ - { - "expression": "market_cap", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "coin_current_price_idx": { - "name": "coin_current_price_idx", - "columns": [ - { - "expression": "current_price", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "coin_change24h_idx": { - "name": "coin_change24h_idx", - "columns": [ - { - "expression": "change_24h", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "coin_volume24h_idx": { - "name": "coin_volume24h_idx", - "columns": [ - { - "expression": "volume_24h", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "coin_created_at_idx": { - "name": "coin_created_at_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "coin_creator_id_user_id_fk": { - "name": "coin_creator_id_user_id_fk", - "tableFrom": "coin", - "tableTo": "user", - "columnsFrom": [ - "creator_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "coin_symbol_unique": { - "name": "coin_symbol_unique", - "nullsNotDistinct": false, - "columns": [ - "symbol" - ] - } - } - }, - "public.comment": { - "name": "comment", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "coin_id": { - "name": "coin_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "varchar(500)", - "primaryKey": false, - "notNull": true - }, - "likes_count": { - "name": "likes_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "is_deleted": { - "name": "is_deleted", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - } - }, - "indexes": { - "comment_user_id_idx": { - "name": "comment_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "comment_coin_id_idx": { - "name": "comment_coin_id_idx", - "columns": [ - { - "expression": "coin_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "comment_user_id_user_id_fk": { - "name": "comment_user_id_user_id_fk", - "tableFrom": "comment", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "comment_coin_id_coin_id_fk": { - "name": "comment_coin_id_coin_id_fk", - "tableFrom": "comment", - "tableTo": "coin", - "columnsFrom": [ - "coin_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.comment_like": { - "name": "comment_like", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "comment_id": { - "name": "comment_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "comment_like_user_id_user_id_fk": { - "name": "comment_like_user_id_user_id_fk", - "tableFrom": "comment_like", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "comment_like_comment_id_comment_id_fk": { - "name": "comment_like_comment_id_comment_id_fk", - "tableFrom": "comment_like", - "tableTo": "comment", - "columnsFrom": [ - "comment_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "comment_like_user_id_comment_id_pk": { - "name": "comment_like_user_id_comment_id_pk", - "columns": [ - "user_id", - "comment_id" - ] - } - }, - "uniqueConstraints": {} - }, - "public.notification": { - "name": "notification", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "notification_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "varchar(200)", - "primaryKey": false, - "notNull": true - }, - "message": { - "name": "message", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_read": { - "name": "is_read", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "notification_user_id_idx": { - "name": "notification_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "notification_type_idx": { - "name": "notification_type_idx", - "columns": [ - { - "expression": "type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "notification_is_read_idx": { - "name": "notification_is_read_idx", - "columns": [ - { - "expression": "is_read", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "notification_created_at_idx": { - "name": "notification_created_at_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "notification_user_id_user_id_fk": { - "name": "notification_user_id_user_id_fk", - "tableFrom": "notification", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.prediction_bet": { - "name": "prediction_bet", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "question_id": { - "name": "question_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "side": { - "name": "side", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "amount": { - "name": "amount", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "actual_winnings": { - "name": "actual_winnings", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "settled_at": { - "name": "settled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "prediction_bet_user_id_idx": { - "name": "prediction_bet_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_bet_question_id_idx": { - "name": "prediction_bet_question_id_idx", - "columns": [ - { - "expression": "question_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_bet_user_question_idx": { - "name": "prediction_bet_user_question_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "question_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_bet_created_at_idx": { - "name": "prediction_bet_created_at_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "prediction_bet_user_id_user_id_fk": { - "name": "prediction_bet_user_id_user_id_fk", - "tableFrom": "prediction_bet", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "prediction_bet_question_id_prediction_question_id_fk": { - "name": "prediction_bet_question_id_prediction_question_id_fk", - "tableFrom": "prediction_bet", - "tableTo": "prediction_question", - "columnsFrom": [ - "question_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.prediction_question": { - "name": "prediction_question", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "creator_id": { - "name": "creator_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "question": { - "name": "question", - "type": "varchar(200)", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "prediction_market_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'ACTIVE'" - }, - "resolution_date": { - "name": "resolution_date", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "ai_resolution": { - "name": "ai_resolution", - "type": "boolean", - "primaryKey": false, - "notNull": false - }, - "total_yes_amount": { - "name": "total_yes_amount", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true, - "default": "'0.00000000'" - }, - "total_no_amount": { - "name": "total_no_amount", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true, - "default": "'0.00000000'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "resolved_at": { - "name": "resolved_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "requires_web_search": { - "name": "requires_web_search", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "validation_reason": { - "name": "validation_reason", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "prediction_question_creator_id_idx": { - "name": "prediction_question_creator_id_idx", - "columns": [ - { - "expression": "creator_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_question_status_idx": { - "name": "prediction_question_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_question_resolution_date_idx": { - "name": "prediction_question_resolution_date_idx", - "columns": [ - { - "expression": "resolution_date", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "prediction_question_status_resolution_idx": { - "name": "prediction_question_status_resolution_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resolution_date", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "prediction_question_creator_id_user_id_fk": { - "name": "prediction_question_creator_id_user_id_fk", - "tableFrom": "prediction_question", - "tableTo": "user", - "columnsFrom": [ - "creator_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.price_history": { - "name": "price_history", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "coin_id": { - "name": "coin_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "price": { - "name": "price", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "timestamp": { - "name": "timestamp", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "price_history_coin_id_coin_id_fk": { - "name": "price_history_coin_id_coin_id_fk", - "tableFrom": "price_history", - "tableTo": "coin", - "columnsFrom": [ - "coin_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.promo_code": { - "name": "promo_code", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "code": { - "name": "code", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "reward_amount": { - "name": "reward_amount", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "max_uses": { - "name": "max_uses", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "is_active": { - "name": "is_active", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "created_by": { - "name": "created_by", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "promo_code_created_by_user_id_fk": { - "name": "promo_code_created_by_user_id_fk", - "tableFrom": "promo_code", - "tableTo": "user", - "columnsFrom": [ - "created_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "promo_code_code_unique": { - "name": "promo_code_code_unique", - "nullsNotDistinct": false, - "columns": [ - "code" - ] - } - } - }, - "public.promo_code_redemption": { - "name": "promo_code_redemption", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "promo_code_id": { - "name": "promo_code_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "reward_amount": { - "name": "reward_amount", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "redeemed_at": { - "name": "redeemed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "promo_code_redemption_user_id_user_id_fk": { - "name": "promo_code_redemption_user_id_user_id_fk", - "tableFrom": "promo_code_redemption", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "promo_code_redemption_promo_code_id_promo_code_id_fk": { - "name": "promo_code_redemption_promo_code_id_promo_code_id_fk", - "tableFrom": "promo_code_redemption", - "tableTo": "promo_code", - "columnsFrom": [ - "promo_code_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "promo_code_redemption_user_id_promo_code_id_unique": { - "name": "promo_code_redemption_user_id_promo_code_id_unique", - "nullsNotDistinct": false, - "columns": [ - "user_id", - "promo_code_id" - ] - } - } - }, - "public.session": { - "name": "session", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "token": { - "name": "token", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "ip_address": { - "name": "ip_address", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "session_user_id_user_id_fk": { - "name": "session_user_id_user_id_fk", - "tableFrom": "session", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "session_token_unique": { - "name": "session_token_unique", - "nullsNotDistinct": false, - "columns": [ - "token" - ] - } - } - }, - "public.transaction": { - "name": "transaction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "coin_id": { - "name": "coin_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "type": { - "name": "type", - "type": "transaction_type", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "quantity": { - "name": "quantity", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true - }, - "price_per_coin": { - "name": "price_per_coin", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true - }, - "total_base_currency_amount": { - "name": "total_base_currency_amount", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true - }, - "timestamp": { - "name": "timestamp", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "recipient_user_id": { - "name": "recipient_user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "sender_user_id": { - "name": "sender_user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "transaction_user_id_idx": { - "name": "transaction_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "transaction_coin_id_idx": { - "name": "transaction_coin_id_idx", - "columns": [ - { - "expression": "coin_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "transaction_type_idx": { - "name": "transaction_type_idx", - "columns": [ - { - "expression": "type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "transaction_timestamp_idx": { - "name": "transaction_timestamp_idx", - "columns": [ - { - "expression": "timestamp", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "transaction_user_coin_idx": { - "name": "transaction_user_coin_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "coin_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "transaction_coin_type_idx": { - "name": "transaction_coin_type_idx", - "columns": [ - { - "expression": "coin_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "transaction_user_id_user_id_fk": { - "name": "transaction_user_id_user_id_fk", - "tableFrom": "transaction", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "transaction_coin_id_coin_id_fk": { - "name": "transaction_coin_id_coin_id_fk", - "tableFrom": "transaction", - "tableTo": "coin", - "columnsFrom": [ - "coin_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "transaction_recipient_user_id_user_id_fk": { - "name": "transaction_recipient_user_id_user_id_fk", - "tableFrom": "transaction", - "tableTo": "user", - "columnsFrom": [ - "recipient_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "transaction_sender_user_id_user_id_fk": { - "name": "transaction_sender_user_id_user_id_fk", - "tableFrom": "transaction", - "tableTo": "user", - "columnsFrom": [ - "sender_user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "public.user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email_verified": { - "name": "email_verified", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "image": { - "name": "image", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "is_admin": { - "name": "is_admin", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "is_banned": { - "name": "is_banned", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "ban_reason": { - "name": "ban_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "base_currency_balance": { - "name": "base_currency_balance", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true, - "default": "'100.00000000'" - }, - "bio": { - "name": "bio", - "type": "varchar(160)", - "primaryKey": false, - "notNull": false, - "default": "'Hello am 48 year old man from somalia. Sorry for my bed england. I selled my wife for internet connection for play “conter stirk”'" - }, - "username": { - "name": "username", - "type": "varchar(30)", - "primaryKey": false, - "notNull": true - }, - "volume_master": { - "name": "volume_master", - "type": "numeric(3, 2)", - "primaryKey": false, - "notNull": true, - "default": "'0.70'" - }, - "volume_muted": { - "name": "volume_muted", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "last_reward_claim": { - "name": "last_reward_claim", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "total_rewards_claimed": { - "name": "total_rewards_claimed", - "type": "numeric(20, 8)", - "primaryKey": false, - "notNull": true, - "default": "'0.00000000'" - }, - "login_streak": { - "name": "login_streak", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "prestige_level": { - "name": "prestige_level", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - } - }, - "indexes": { - "user_username_idx": { - "name": "user_username_idx", - "columns": [ - { - "expression": "username", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "user_is_banned_idx": { - "name": "user_is_banned_idx", - "columns": [ - { - "expression": "is_banned", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "user_is_admin_idx": { - "name": "user_is_admin_idx", - "columns": [ - { - "expression": "is_admin", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "user_created_at_idx": { - "name": "user_created_at_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "user_updated_at_idx": { - "name": "user_updated_at_idx", - "columns": [ - { - "expression": "updated_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - }, - "user_username_unique": { - "name": "user_username_unique", - "nullsNotDistinct": false, - "columns": [ - "username" - ] - } - } - }, - "public.user_portfolio": { - "name": "user_portfolio", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "coin_id": { - "name": "coin_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "quantity": { - "name": "quantity", - "type": "numeric(30, 8)", - "primaryKey": false, - "notNull": true - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "user_portfolio_user_id_user_id_fk": { - "name": "user_portfolio_user_id_user_id_fk", - "tableFrom": "user_portfolio", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "user_portfolio_coin_id_coin_id_fk": { - "name": "user_portfolio_coin_id_coin_id_fk", - "tableFrom": "user_portfolio", - "tableTo": "coin", - "columnsFrom": [ - "coin_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "user_portfolio_user_id_coin_id_pk": { - "name": "user_portfolio_user_id_coin_id_pk", - "columns": [ - "user_id", - "coin_id" - ] - } - }, - "uniqueConstraints": {} - }, - "public.verification": { - "name": "verification", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "identifier": { - "name": "identifier", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "value": { - "name": "value", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": { - "public.notification_type": { - "name": "notification_type", - "schema": "public", - "values": [ - "HOPIUM", - "SYSTEM", - "TRANSFER", - "RUG_PULL" - ] - }, - "public.prediction_market_status": { - "name": "prediction_market_status", - "schema": "public", - "values": [ - "ACTIVE", - "RESOLVED", - "CANCELLED" - ] - }, - "public.transaction_type": { - "name": "transaction_type", - "schema": "public", - "values": [ - "BUY", - "SELL", - "TRANSFER_IN", - "TRANSFER_OUT" - ] - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/website/drizzle/meta/_journal.json b/website/drizzle/meta/_journal.json index 6f60140..964b39d 100644 --- a/website/drizzle/meta/_journal.json +++ b/website/drizzle/meta/_journal.json @@ -5,29 +5,8 @@ { "idx": 0, "version": "7", - "when": 1749654046953, - "tag": "0000_crazy_bloodstrike", - "breakpoints": true - }, - { - "idx": 1, - "version": "7", - "when": 1749907594739, - "tag": "0001_cuddly_dormammu", - "breakpoints": true - }, - { - "idx": 2, - "version": "7", - "when": 1749916220202, - "tag": "0002_small_micromacro", - "breakpoints": true - }, - { - "idx": 3, - "version": "7", - "when": 1750707307426, - "tag": "0003_complete_runaways", + "when": 1750863600119, + "tag": "0000_chief_korath", "breakpoints": true } ] diff --git a/website/src/lib/auth.ts b/website/src/lib/auth.ts index 523acd2..a29f0bb 100644 --- a/website/src/lib/auth.ts +++ b/website/src/lib/auth.ts @@ -6,6 +6,7 @@ import { db } from "./server/db"; import * as schema from "./server/db/schema"; import { generateUsername } from "./utils/random"; import { uploadProfilePicture } from "./server/s3"; +import { apiKey } from "better-auth/plugins"; if (!env.GOOGLE_CLIENT_ID) throw new Error('GOOGLE_CLIENT_ID is not set'); if (!env.GOOGLE_CLIENT_SECRET) throw new Error('GOOGLE_CLIENT_SECRET is not set'); @@ -19,6 +20,21 @@ export const auth = betterAuth({ env.BETTER_AUTH_URL, "http://rugplay.com", "http://localhost:5173", ], + plugins: [ + apiKey({ + defaultPrefix: 'rgpl_', + rateLimit: { + enabled: true, + timeWindow: 1000 * 60 * 60 * 24, // 1 day + maxRequests: 2000 // 2000 requests per day + }, + permissions: { + defaultPermissions: { + api: ['read'] + } + } + }), + ], database: drizzleAdapter(db, { provider: "pg", schema: schema, diff --git a/website/src/lib/components/self/AppSidebar.svelte b/website/src/lib/components/self/AppSidebar.svelte index 432a87d..c54d63e 100644 --- a/website/src/lib/components/self/AppSidebar.svelte +++ b/website/src/lib/components/self/AppSidebar.svelte @@ -32,7 +32,8 @@ BookOpen, Info, Bell, - Crown + Crown, + Key } from 'lucide-svelte'; import { mode, setMode } from 'mode-watcher'; import type { HTMLAttributes } from 'svelte/elements'; @@ -158,6 +159,11 @@ goto('/prestige'); setOpenMobile(false); } + + function handleAPIClick(){ + goto('/api'); + setOpenMobile(false); + } @@ -411,7 +417,7 @@ - + @@ -427,11 +433,17 @@ Prestige - + - + + + + API + { showPromoCode = true; @@ -483,9 +495,9 @@ {/if} - + - + @@ -497,9 +509,9 @@ Privacy Policy - + - + { diff --git a/website/src/lib/components/self/Codeblock.svelte b/website/src/lib/components/self/Codeblock.svelte new file mode 100644 index 0000000..551e235 --- /dev/null +++ b/website/src/lib/components/self/Codeblock.svelte @@ -0,0 +1,47 @@ + + +
+ + {text} + + + {#if !displayOnly} + + {/if} +
\ No newline at end of file diff --git a/website/src/lib/components/ui/collapsible/collapsible-content.svelte b/website/src/lib/components/ui/collapsible/collapsible-content.svelte new file mode 100644 index 0000000..bdabb55 --- /dev/null +++ b/website/src/lib/components/ui/collapsible/collapsible-content.svelte @@ -0,0 +1,7 @@ + + + diff --git a/website/src/lib/components/ui/collapsible/collapsible-trigger.svelte b/website/src/lib/components/ui/collapsible/collapsible-trigger.svelte new file mode 100644 index 0000000..ece7ad6 --- /dev/null +++ b/website/src/lib/components/ui/collapsible/collapsible-trigger.svelte @@ -0,0 +1,7 @@ + + + diff --git a/website/src/lib/components/ui/collapsible/collapsible.svelte b/website/src/lib/components/ui/collapsible/collapsible.svelte new file mode 100644 index 0000000..39cdd4e --- /dev/null +++ b/website/src/lib/components/ui/collapsible/collapsible.svelte @@ -0,0 +1,11 @@ + + + diff --git a/website/src/lib/components/ui/collapsible/index.ts b/website/src/lib/components/ui/collapsible/index.ts new file mode 100644 index 0000000..169b479 --- /dev/null +++ b/website/src/lib/components/ui/collapsible/index.ts @@ -0,0 +1,13 @@ +import Root from "./collapsible.svelte"; +import Trigger from "./collapsible-trigger.svelte"; +import Content from "./collapsible-content.svelte"; + +export { + Root, + Content, + Trigger, + // + Root as Collapsible, + Content as CollapsibleContent, + Trigger as CollapsibleTrigger, +}; diff --git a/website/src/lib/server/api-auth.ts b/website/src/lib/server/api-auth.ts new file mode 100644 index 0000000..7494f1e --- /dev/null +++ b/website/src/lib/server/api-auth.ts @@ -0,0 +1,20 @@ +import { auth } from "$lib/auth"; +import { error } from "@sveltejs/kit"; + +export async function verifyApiKeyAndGetUser(request: Request) { + const authHeader = request.headers.get('Authorization'); + if (!authHeader?.startsWith('Bearer ')) { + throw error(401, 'API key required. Use Authorization: Bearer '); + } + + const apiKeyStr = authHeader.substring(7); + const { valid, error: verifyError, key } = await auth.api.verifyApiKey({ + body: { key: apiKeyStr } + }); + + if (verifyError || !valid || !key) { + throw error(401, 'Invalid API key'); + } + + return key.userId; +} \ No newline at end of file diff --git a/website/src/lib/server/db/schema.ts b/website/src/lib/server/db/schema.ts index e6b6420..40abe7e 100644 --- a/website/src/lib/server/db/schema.ts +++ b/website/src/lib/server/db/schema.ts @@ -274,4 +274,30 @@ export const notifications = pgTable("notification", { isReadIdx: index("notification_is_read_idx").on(table.isRead), createdAtIdx: index("notification_created_at_idx").on(table.createdAt), }; -}); \ No newline at end of file +}); + +export const apikey = pgTable("apikey", { + id: serial("id").primaryKey(), + name: text('name'), + start: text('start'), + prefix: text('prefix'), + key: text('key').notNull(), + userId: integer('user_id').notNull().references(() => user.id, { onDelete: 'cascade' }), + refillInterval: integer('refill_interval'), + refillAmount: integer('refill_amount'), + lastRefillAt: timestamp('last_refill_at'), + enabled: boolean('enabled'), + rateLimitEnabled: boolean('rate_limit_enabled'), + rateLimitTimeWindow: integer('rate_limit_time_window'), + rateLimitMax: integer('rate_limit_max'), + requestCount: integer('request_count'), + remaining: integer('remaining'), + lastRequest: timestamp('last_request'), + expiresAt: timestamp('expires_at'), + createdAt: timestamp('created_at').notNull(), + updatedAt: timestamp('updated_at').notNull(), + permissions: text('permissions'), + metadata: text('metadata') +}, (table) => ({ + userIdx: index("idx_apikey_user").on(table.userId) +})); \ No newline at end of file diff --git a/website/src/routes/api/+page.server.ts b/website/src/routes/api/+page.server.ts new file mode 100644 index 0000000..636b764 --- /dev/null +++ b/website/src/routes/api/+page.server.ts @@ -0,0 +1,20 @@ +import { auth } from '$lib/auth'; +import type { PageServerLoad } from './$types'; + +export const load: PageServerLoad = async (event) => { + const session = await auth.api.getSession({ headers: event.request.headers }); + + if (!session?.user) { + return { apiKey: null, todayUsage: 0 }; + } + + const keys = await auth.api.listApiKeys({ headers: event.request.headers }); + const key = keys.length > 0 ? keys[0] : null; + + const todayUsage = key ? 2000 - (key.remaining || 0) : 0; + + return { + apiKey: key, + todayUsage + }; +}; diff --git a/website/src/routes/api/+page.svelte b/website/src/routes/api/+page.svelte new file mode 100644 index 0000000..5ab62cc --- /dev/null +++ b/website/src/routes/api/+page.svelte @@ -0,0 +1,650 @@ + + + + +
+
+

API Access

+

Manage your API access and usage

+
+ + {#if !$USER_DATA} + + + +

Sign in required

+

+ Sign in to get your free API key. +

+ +
+
+ {:else} + + + + + + Today's Usage + + + +
+
+ {todayUsage.toLocaleString()} requests + {maxDailyRequests.toLocaleString()} max +
+ +

+ {Math.max(0, maxDailyRequests - todayUsage).toLocaleString()} requests remaining today +

+
+
+
+ + + + +
+
+ API Key +

+ Use this key to authenticate your API requests +

+
+ {#if apiKeyId} + + {/if} +
+
+ + {#if apiKey && justCreated} +
+ + + + + This is the only time your full API key will be shown. If you lose it, you'll need + to create a new one. + + +
+ {:else if !apiKey && data.apiKey && apiKeyId} +
+ +

+ For security reasons, the full API key is only shown once upon creation. If you've + lost your key, you'll need to regenerate it. +

+
+ {:else} + + {/if} +
+
+ + + + + API Documentation + + + + + +

Authentication

+ {#if authOpen} + + {:else} + + {/if} +
+ +

+ Include your API key in the Authorization header for all requests: +

+ +
+
+ + + + +
+

Get Top Coins

+

GET /api/v1/top

+
+ {#if topCoinsOpen} + + {:else} + + {/if} +
+ +

+ Returns the top 50 coins by market cap. +

+
+

Endpoint

+ +
+
+

Example Response

+ +
+
+
+ + + + +
+

Get Market Data

+

GET /api/v1/market

+
+ {#if marketDataOpen} + + {:else} + + {/if} +
+ +

+ Returns paginated market data with filtering and sorting options. +

+
+

Endpoint

+ +
+
+

Query Parameters

+
+
+
search - Search by coin name or symbol
+
sortBy - Sort field: marketCap, currentPrice, change24h, volume24h, createdAt (default: marketCap)
+
sortOrder - Sort order: asc, desc (default: desc)
+
priceFilter - Price range: all, under1, 1to10, 10to100, over100 (default: all)
+
changeFilter - Change filter: all, gainers, losers, hot, wild (default: all)
+
page - Page number (default: 1)
+
limit - Items per page, max 100 (default: 12)
+
+
+
+
+

Example Response

+ +
+
+
+ + + + +
+

Get Coin Details

+

GET /api/v1/coin/{symbol}

+
+ {#if coinDetailsOpen} + + {:else} + + {/if} +
+ +

+ Returns detailed information about a specific coin including price history. +

+
+

Endpoint

+ +
+
+

Parameters

+
+
+
symbol - Coin symbol (e.g., "TEST")
+
timeframe - Optional. Chart timeframe: 1m, 5m, 15m, 1h, 4h, 1d (default: 1m)
+
+
+
+
+

Example Response

+ +
+
+
+ + + + +
+

Get Coin Holders

+

GET /api/v1/holders/{symbol}

+
+ {#if holdersOpen} + + {:else} + + {/if} +
+ +

+ Returns the top 50 holders of a specific coin. +

+
+

Endpoint

+ +
+
+

Parameters

+
+
+
symbol - Coin symbol (e.g., "TEST")
+
limit - Number of holders to return, max 200 (default: 50)
+
+
+
+
+

Example Response

+ +
+
+
+ + + + +
+

Get Prediction Markets (Hopium)

+

GET /api/v1/hopium

+
+ {#if hopiumOpen} + + {:else} + + {/if} +
+ +

+ Returns prediction market questions with pagination and filtering options. +

+
+

Endpoint

+ +
+
+

Query Parameters

+
+
+
status - Filter by status: ACTIVE, RESOLVED, CANCELLED, ALL (default: ACTIVE)
+
page - Page number (default: 1)
+
limit - Items per page, max 100 (default: 20)
+
+
+
+
+

Example Response

+ +
+
+
+ + + + +
+

Get Prediction Market Details

+

GET /api/v1/hopium/{question_id}

+
+ {#if hopiumDetailsOpen} + + {:else} + + {/if} +
+ +

+ Returns detailed information about a specific prediction market question including recent bets and probability history. +

+
+

Endpoint

+ +
+
+

Parameters

+
+
+
question_id - Question ID (e.g., 101)
+
+
+
+
+

Example Response

+ +
+
+
+ + + + +

Rate Limiting

+ {#if rateLimitingOpen} + + {:else} + + {/if} +
+ +
+
+
Daily limit: {maxDailyRequests.toLocaleString()} requests per day
+
Cost: 1 credit per API call
+
Error response: 429 Too Many Requests when limit exceeded
+
Reset: Daily limits reset every 24 hours
+
+
+
+
+ + + + +

Error Responses

+ {#if errorResponsesOpen} + + {:else} + + {/if} +
+ +

Common Error Codes

+
+
+
400 - Bad Request (invalid parameters)
+
401 - Unauthorized (invalid or missing API key)
+
404 - Not Found (coin/question doesn't exist)
+
429 - Too Many Requests (rate limit exceeded)
+
500 - Internal Server Error
+
+
+
+
+
+
+ {/if} +
diff --git a/website/src/routes/api/keys/+server.ts b/website/src/routes/api/keys/+server.ts new file mode 100644 index 0000000..d227592 --- /dev/null +++ b/website/src/routes/api/keys/+server.ts @@ -0,0 +1,51 @@ +import { json, error } from '@sveltejs/kit'; +import { auth } from '$lib/auth'; +import type { RequestHandler } from './$types'; + +export const GET: RequestHandler = async (event) => { + const session = await auth.api.getSession({ + headers: event.request.headers + }); + + if (!session?.user) { + throw error(401, 'Not authenticated'); + } + + const keys = await auth.api.listApiKeys({ + headers: event.request.headers + }); + + return json(keys); +}; + +export const POST: RequestHandler = async (event) => { + const session = await auth.api.getSession({ + headers: event.request.headers + }); + + if (!session?.user) { + throw error(401, 'Not authenticated'); + } + + const existingKeys = await auth.api.listApiKeys({ + headers: event.request.headers + }); + + if (existingKeys.length > 0) { + throw error(400, 'You can only have one API key at a time'); + } + + const apiKey = await auth.api.createApiKey({ + body: { + name: "API Key", + remaining: 2000, + permissions: { + api: ['read'] + }, + userId: session.user.id + }, + headers: event.request.headers + }); + + return json(apiKey); +}; diff --git a/website/src/routes/api/keys/[id]/+server.ts b/website/src/routes/api/keys/[id]/+server.ts new file mode 100644 index 0000000..affce93 --- /dev/null +++ b/website/src/routes/api/keys/[id]/+server.ts @@ -0,0 +1,49 @@ +import { json, error } from '@sveltejs/kit'; +import { auth } from '$lib/auth'; +import type { RequestHandler } from './$types'; + +export const GET: RequestHandler = async (event) => { + const session = await auth.api.getSession({ + headers: event.request.headers + }); + + if (!session?.user) { + throw error(401, 'Not authenticated'); + } + + const keyId = event.params.id; + + try { + const key = await auth.api.getApiKey({ + query: { id: keyId }, + headers: event.request.headers + }); + + if (!key) { + throw error(404, 'API key not found'); + } + + return json(key); + } catch (err) { + throw error(404, 'API key not found'); + } +}; + +export const DELETE: RequestHandler = async (event) => { + const session = await auth.api.getSession({ + headers: event.request.headers + }); + + if (!session?.user) { + throw error(401, 'Not authenticated'); + } + + const keyId = event.params.id; + + await auth.api.deleteApiKey({ + body: { keyId }, + headers: event.request.headers + }); + + return json({ success: true }); +}; \ No newline at end of file diff --git a/website/src/routes/api/keys/[id]/regenerate/+server.ts b/website/src/routes/api/keys/[id]/regenerate/+server.ts new file mode 100644 index 0000000..11b1458 --- /dev/null +++ b/website/src/routes/api/keys/[id]/regenerate/+server.ts @@ -0,0 +1,62 @@ +import { json, error } from '@sveltejs/kit'; +import { auth } from '$lib/auth'; +import type { RequestHandler } from './$types'; + +export const POST: RequestHandler = async (event) => { + const session = await auth.api.getSession({ + headers: event.request.headers + }); + + if (!session?.user) { + throw error(401, 'Not authenticated'); + } + + const existingKey = await auth.api.getApiKey({ + query: { id: event.params.id }, + headers: event.request.headers + }); + + if (!existingKey) { + throw error(404, 'API key not found'); + } + + if (existingKey.userId !== session.user.id) { + throw error(403, 'Not authorized to regenerate this API key'); + } + + console.log(existingKey.remaining) + await auth.api.deleteApiKey({ + body: { keyId: event.params.id }, + headers: event.request.headers + }); + + let parsedPermissions: Record | undefined = existingKey.permissions as Record | undefined; + if (typeof existingKey.permissions === 'string') { + try { + const parsed = JSON.parse(existingKey.permissions); + parsedPermissions = parsed && typeof parsed === 'object' ? parsed : undefined; + } catch { + parsedPermissions = undefined; + } + } + + const newKey = await auth.api.createApiKey({ + body: { + name: existingKey.name ?? undefined, + userId: existingKey.userId, + remaining: existingKey.remaining, + refillAmount: existingKey.refillAmount ?? undefined, + refillInterval: existingKey.refillInterval ?? undefined, + rateLimitEnabled: existingKey.rateLimitEnabled, + rateLimitTimeWindow: existingKey.rateLimitTimeWindow ?? undefined, + rateLimitMax: existingKey.rateLimitMax ?? undefined, + permissions: parsedPermissions, + metadata: existingKey.metadata + }, + headers: event.request.headers + }); + console.log(existingKey.remaining) + console.log(newKey.remaining) + + return json(newKey); +}; \ No newline at end of file diff --git a/website/src/routes/api/v1/coin/[coinSymbol]/+server.ts b/website/src/routes/api/v1/coin/[coinSymbol]/+server.ts new file mode 100644 index 0000000..d97c960 --- /dev/null +++ b/website/src/routes/api/v1/coin/[coinSymbol]/+server.ts @@ -0,0 +1,8 @@ +import { GET as getCoinData } from '../../../coin/[coinSymbol]/+server'; +import { verifyApiKeyAndGetUser } from '$lib/server/api-auth'; + +export async function GET({ params, url, request }) { + await verifyApiKeyAndGetUser(request); + + return await getCoinData({ params, url }); +} \ No newline at end of file diff --git a/website/src/routes/api/v1/holders/[coinSymbol]/+server.ts b/website/src/routes/api/v1/holders/[coinSymbol]/+server.ts new file mode 100644 index 0000000..9c0e7d9 --- /dev/null +++ b/website/src/routes/api/v1/holders/[coinSymbol]/+server.ts @@ -0,0 +1,8 @@ +import { GET as getHoldersData } from '../../../coin/[coinSymbol]/holders/+server'; +import { verifyApiKeyAndGetUser } from '$lib/server/api-auth'; + +export async function GET({ params, url, request }) { + await verifyApiKeyAndGetUser(request); + + return await getHoldersData({ params, url }); +} diff --git a/website/src/routes/api/v1/hopium/+server.ts b/website/src/routes/api/v1/hopium/+server.ts new file mode 100644 index 0000000..37d872b --- /dev/null +++ b/website/src/routes/api/v1/hopium/+server.ts @@ -0,0 +1,19 @@ +import { GET as getHopiumQuestions } from '../../hopium/questions/+server'; +import { verifyApiKeyAndGetUser } from '$lib/server/api-auth'; + +export async function GET({ url, request }) { + await verifyApiKeyAndGetUser(request); + + const hopiumEvent = { + request, + url, + cookies: arguments[0].cookies, + fetch: arguments[0].fetch, + getClientAddress: arguments[0].getClientAddress, + locals: arguments[0].locals, + platform: arguments[0].platform, + route: { id: "/api/hopium/questions" } + }; + + return await getHopiumQuestions(hopiumEvent as any); +} diff --git a/website/src/routes/api/v1/hopium/[id]/+server.ts b/website/src/routes/api/v1/hopium/[id]/+server.ts new file mode 100644 index 0000000..1c3f9b5 --- /dev/null +++ b/website/src/routes/api/v1/hopium/[id]/+server.ts @@ -0,0 +1,20 @@ +import { GET as getHopiumQuestion } from '../../../hopium/questions/[id]/+server'; +import { verifyApiKeyAndGetUser } from '$lib/server/api-auth'; + +export async function GET(event) { + await verifyApiKeyAndGetUser(event.request); + + const hopiumEvent = { + params: event.params, + request: event.request, + url: event.url, + cookies: event.cookies, + fetch: event.fetch, + getClientAddress: event.getClientAddress, + locals: event.locals, + platform: event.platform, + route: { id: "/api/hopium/questions/[id]" } + }; + + return await getHopiumQuestion(hopiumEvent); +} diff --git a/website/src/routes/api/v1/market/+server.ts b/website/src/routes/api/v1/market/+server.ts new file mode 100644 index 0000000..8c46d3a --- /dev/null +++ b/website/src/routes/api/v1/market/+server.ts @@ -0,0 +1,7 @@ +import { verifyApiKeyAndGetUser } from '$lib/server/api-auth'; +import { GET as getMarketData } from '../../market/+server'; + +export async function GET({ url, request }) { + await verifyApiKeyAndGetUser(request); + return await getMarketData({ url }); +} diff --git a/website/src/routes/api/v1/top/+server.ts b/website/src/routes/api/v1/top/+server.ts new file mode 100644 index 0000000..d694aa3 --- /dev/null +++ b/website/src/routes/api/v1/top/+server.ts @@ -0,0 +1,7 @@ +import { verifyApiKeyAndGetUser } from '$lib/server/api-auth'; +import { GET as getTopCoins } from '../../coins/top/+server'; + +export async function GET({ request }) { + await verifyApiKeyAndGetUser(request); + return await getTopCoins(); +}