Skip to content

Commit

Permalink
www
Browse files Browse the repository at this point in the history
  • Loading branch information
dromzeh committed Nov 26, 2023
1 parent 6df505a commit 15ab11a
Show file tree
Hide file tree
Showing 14 changed files with 416 additions and 1,555 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

![Quality]

Source code for the API powering [**wanderer.moe**](https://wanderer.moe) — using **Cloudflare Workers** and **Hono** with **R2 Storage** for the CDN, **Turso** and **Drizzle** for the Database and **KV** for session storage.
Source code for the API powering [**wanderer.moe**](https://wanderer.moe) — using **Cloudflare Workers** and **Hono** with **R2 Storage** for the CDN, **Turso** and **Drizzle**.

</div>

Expand Down
2 changes: 2 additions & 0 deletions src/v2/db/drizzle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export const tableNames = {
authUser: "authUser",
userNetworking: "userNetworking",
gameAssetCategory: "gameAssetCategory",
assetNetworking: "assetNetworking",
userCollectionNetworking: "collectionNetworking",
game: "game",
atlas: "atlas",
atlasToAsset: "atlasToAsset",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ CREATE TABLE `atlasToAsset` (
FOREIGN KEY (`asset_id`) REFERENCES `asset`(`id`) ON UPDATE cascade ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `assetNetworking` (
`follower_id` text NOT NULL,
`following_id` text NOT NULL,
`created_at` text NOT NULL,
FOREIGN KEY (`follower_id`) REFERENCES `authUser`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`following_id`) REFERENCES `authUser`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `game` (
`id` text NOT NULL,
`name` text NOT NULL,
Expand All @@ -89,6 +97,13 @@ CREATE TABLE `savedOcGenerators` (
FOREIGN KEY (`user_id`) REFERENCES `authUser`(`id`) ON UPDATE cascade ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `authKey` (
`id` text NOT NULL,
`user_id` text NOT NULL,
`hashed_password` text,
FOREIGN KEY (`user_id`) REFERENCES `authUser`(`id`) ON UPDATE cascade ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `authUser` (
`id` text NOT NULL,
`avatar_url` text,
Expand All @@ -107,10 +122,11 @@ CREATE TABLE `authUser` (
`self_assignable_role_flags` integer DEFAULT 0 NOT NULL
);
--> statement-breakpoint
CREATE TABLE `authKey` (
CREATE TABLE `authSession` (
`id` text NOT NULL,
`active_expires` integer NOT NULL,
`idle_expires` integer NOT NULL,
`user_id` text NOT NULL,
`hashed_password` text,
FOREIGN KEY (`user_id`) REFERENCES `authUser`(`id`) ON UPDATE cascade ON DELETE cascade
);
--> statement-breakpoint
Expand Down Expand Up @@ -178,6 +194,14 @@ CREATE TABLE `userNetworking` (
FOREIGN KEY (`followingId`) REFERENCES `authUser`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `collectionNetworking` (
`collection_id` text NOT NULL,
`liked_by_id` text NOT NULL,
`createdAt` text NOT NULL,
FOREIGN KEY (`collection_id`) REFERENCES `userCollection`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`liked_by_id`) REFERENCES `authUser`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE INDEX `assets_id_idx` ON `asset` (`id`);--> statement-breakpoint
CREATE INDEX `assets_name_idx` ON `asset` (`name`);--> statement-breakpoint
CREATE INDEX `assets_game_name_idx` ON `asset` (`game`);--> statement-breakpoint
Expand All @@ -202,20 +226,24 @@ CREATE INDEX `atlas_uploaded_by_name_idx` ON `atlas` (`uploaded_by_name`);--> st
CREATE INDEX `atlas_to_assets_id_idx` ON `atlasToAsset` (`id`);--> statement-breakpoint
CREATE INDEX `atlas_to_assets_atlas_id_idx` ON `atlasToAsset` (`atlas_id`);--> statement-breakpoint
CREATE INDEX `atlas_to_assets_asset_id_idx` ON `atlasToAsset` (`asset_id`);--> statement-breakpoint
CREATE INDEX `assetNetworking_likedAsset_idx` ON `assetNetworking` (`follower_id`);--> statement-breakpoint
CREATE INDEX `assetNetworking_likedBy_idx` ON `assetNetworking` (`following_id`);--> statement-breakpoint
CREATE UNIQUE INDEX `game_id_unique` ON `game` (`id`);--> statement-breakpoint
CREATE UNIQUE INDEX `game_name_unique` ON `game` (`name`);--> statement-breakpoint
CREATE INDEX `game_id_idx` ON `game` (`id`);--> statement-breakpoint
CREATE INDEX `game_name_idx` ON `game` (`name`);--> statement-breakpoint
CREATE UNIQUE INDEX `savedOcGenerators_id_unique` ON `savedOcGenerators` (`id`);--> statement-breakpoint
CREATE INDEX `saved_oc_generators_id_idx` ON `savedOcGenerators` (`id`);--> statement-breakpoint
CREATE INDEX `saved_oc_generators_user_id_idx` ON `savedOcGenerators` (`user_id`);--> statement-breakpoint
CREATE UNIQUE INDEX `authKey_id_unique` ON `authKey` (`id`);--> statement-breakpoint
CREATE INDEX `key_user_id_idx` ON `authKey` (`user_id`);--> statement-breakpoint
CREATE UNIQUE INDEX `authUser_id_unique` ON `authUser` (`id`);--> statement-breakpoint
CREATE UNIQUE INDEX `authUser_username_unique` ON `authUser` (`username`);--> statement-breakpoint
CREATE INDEX `user_id_idx` ON `authUser` (`id`);--> statement-breakpoint
CREATE INDEX `user_username_idx` ON `authUser` (`username`);--> statement-breakpoint
CREATE INDEX `user_email_idx` ON `authUser` (`email`);--> statement-breakpoint
CREATE UNIQUE INDEX `authKey_id_unique` ON `authKey` (`id`);--> statement-breakpoint
CREATE INDEX `key_user_id_idx` ON `authKey` (`user_id`);--> statement-breakpoint
CREATE UNIQUE INDEX `authSession_id_unique` ON `authSession` (`id`);--> statement-breakpoint
CREATE INDEX `session_user_id_idx` ON `authSession` (`user_id`);--> statement-breakpoint
CREATE UNIQUE INDEX `emailVerificationToken_id_unique` ON `emailVerificationToken` (`id`);--> statement-breakpoint
CREATE INDEX `email_verification_token_user_id_idx` ON `emailVerificationToken` (`user_id`);--> statement-breakpoint
CREATE INDEX `email_verification_token_token_idx` ON `emailVerificationToken` (`token`);--> statement-breakpoint
Expand All @@ -239,4 +267,6 @@ CREATE INDEX `favorited_assets_assets_id_idx` ON `userFavoriteAsset` (`id`);-->
CREATE INDEX `favorited_assets_assets_user_id_idx` ON `userFavoriteAsset` (`favorited_assets_id`);--> statement-breakpoint
CREATE INDEX `favorited_assets_assets_asset_id_idx` ON `userFavoriteAsset` (`asset_id`);--> statement-breakpoint
CREATE INDEX `userNetworking_follower_idx` ON `userNetworking` (`followerId`);--> statement-breakpoint
CREATE INDEX `userNetworking_following_idx` ON `userNetworking` (`followingId`);
CREATE INDEX `userNetworking_following_idx` ON `userNetworking` (`followingId`);--> statement-breakpoint
CREATE INDEX `userCollectionNetworking_collection_idx` ON `collectionNetworking` (`collection_id`);--> statement-breakpoint
CREATE INDEX `userCollectionNetworking_likedBy_idx` ON `collectionNetworking` (`liked_by_id`);
10 changes: 0 additions & 10 deletions src/v2/db/migrations/0001_chubby_bullseye.sql

This file was deleted.

210 changes: 194 additions & 16 deletions src/v2/db/migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "5",
"dialect": "sqlite",
"id": "f07490ab-84e2-4512-9bfa-2535e05274b7",
"id": "a76d59ea-41c0-4e99-9480-f203e245fbff",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"asset": {
Expand Down Expand Up @@ -563,6 +563,66 @@
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"assetNetworking": {
"name": "assetNetworking",
"columns": {
"follower_id": {
"name": "follower_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"following_id": {
"name": "following_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"assetNetworking_likedAsset_idx": {
"name": "assetNetworking_likedAsset_idx",
"columns": ["follower_id"],
"isUnique": false
},
"assetNetworking_likedBy_idx": {
"name": "assetNetworking_likedBy_idx",
"columns": ["following_id"],
"isUnique": false
}
},
"foreignKeys": {
"assetNetworking_follower_id_authUser_id_fk": {
"name": "assetNetworking_follower_id_authUser_id_fk",
"tableFrom": "assetNetworking",
"tableTo": "authUser",
"columnsFrom": ["follower_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
"assetNetworking_following_id_authUser_id_fk": {
"name": "assetNetworking_following_id_authUser_id_fk",
"tableFrom": "assetNetworking",
"tableTo": "authUser",
"columnsFrom": ["following_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"game": {
"name": "game",
"columns": {
Expand Down Expand Up @@ -736,6 +796,57 @@
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"authKey": {
"name": "authKey",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"hashed_password": {
"name": "hashed_password",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {
"authKey_id_unique": {
"name": "authKey_id_unique",
"columns": ["id"],
"isUnique": true
},
"key_user_id_idx": {
"name": "key_user_id_idx",
"columns": ["user_id"],
"isUnique": false
}
},
"foreignKeys": {
"authKey_user_id_authUser_id_fk": {
"name": "authKey_user_id_authUser_id_fk",
"tableFrom": "authKey",
"tableTo": "authUser",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "cascade"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"authUser": {
"name": "authUser",
"columns": {
Expand Down Expand Up @@ -882,8 +993,8 @@
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"authKey": {
"name": "authKey",
"authSession": {
"name": "authSession",
"columns": {
"id": {
"name": "id",
Expand All @@ -892,37 +1003,44 @@
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"active_expires": {
"name": "active_expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"hashed_password": {
"name": "hashed_password",
"idle_expires": {
"name": "idle_expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"authKey_id_unique": {
"name": "authKey_id_unique",
"authSession_id_unique": {
"name": "authSession_id_unique",
"columns": ["id"],
"isUnique": true
},
"key_user_id_idx": {
"name": "key_user_id_idx",
"session_user_id_idx": {
"name": "session_user_id_idx",
"columns": ["user_id"],
"isUnique": false
}
},
"foreignKeys": {
"authKey_user_id_authUser_id_fk": {
"name": "authKey_user_id_authUser_id_fk",
"tableFrom": "authKey",
"authSession_user_id_authUser_id_fk": {
"name": "authSession_user_id_authUser_id_fk",
"tableFrom": "authSession",
"tableTo": "authUser",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
Expand Down Expand Up @@ -1444,6 +1562,66 @@
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"collectionNetworking": {
"name": "collectionNetworking",
"columns": {
"collection_id": {
"name": "collection_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"liked_by_id": {
"name": "liked_by_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"userCollectionNetworking_collection_idx": {
"name": "userCollectionNetworking_collection_idx",
"columns": ["collection_id"],
"isUnique": false
},
"userCollectionNetworking_likedBy_idx": {
"name": "userCollectionNetworking_likedBy_idx",
"columns": ["liked_by_id"],
"isUnique": false
}
},
"foreignKeys": {
"collectionNetworking_collection_id_userCollection_id_fk": {
"name": "collectionNetworking_collection_id_userCollection_id_fk",
"tableFrom": "collectionNetworking",
"tableTo": "userCollection",
"columnsFrom": ["collection_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
"collectionNetworking_liked_by_id_authUser_id_fk": {
"name": "collectionNetworking_liked_by_id_authUser_id_fk",
"tableFrom": "collectionNetworking",
"tableTo": "authUser",
"columnsFrom": ["liked_by_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
Expand Down
Loading

0 comments on commit 15ab11a

Please sign in to comment.