Skip to content

Commit

Permalink
feat: auth (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiBread authored Jul 14, 2024
1 parent 78ec16c commit 8ffd3a5
Show file tree
Hide file tree
Showing 27 changed files with 2,613 additions and 53 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"emmet.showExpandedAbbreviation": "never"
"emmet.showExpandedAbbreviation": "never",
"typescript.preferences.importModuleSpecifierEnding": "minimal"
}
10 changes: 10 additions & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "drizzle-kit";

export default defineConfig({
dialect: "postgresql",
schema: "./src/lib/server/database/schema.ts",
out: "./migrations",
dbCredentials: {
url: process.env.DATABASE_URL!,
},
});
18 changes: 18 additions & 0 deletions migrations/0000_hot_madame_web.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE IF NOT EXISTS "sessions" (
"id" text PRIMARY KEY NOT NULL,
"user_id" text NOT NULL,
"expires_at" timestamp with time zone NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "users" (
"id" text PRIMARY KEY NOT NULL,
"member_id" text NOT NULL,
"bungie_name" text NOT NULL,
"display_name" text NOT NULL
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
91 changes: 91 additions & 0 deletions migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"id": "bcc3a18c-7da2-45fe-9e47-9d20e3ff3833",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.sessions": {
"name": "sessions",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"expires_at": {
"name": "expires_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {
"sessions_user_id_users_id_fk": {
"name": "sessions_user_id_users_id_fk",
"tableFrom": "sessions",
"tableTo": "users",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.users": {
"name": "users",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"member_id": {
"name": "member_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"bungie_name": {
"name": "bungie_name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"display_name": {
"name": "display_name",
"type": "text",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"schemas": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
13 changes: 13 additions & 0 deletions migrations/meta/_journal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "7",
"dialect": "postgresql",
"entries": [
{
"idx": 0,
"version": "7",
"when": 1718507880609,
"tag": "0000_hot_madame_web",
"breakpoints": true
}
]
}
20 changes: 16 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write ."
"format": "prettier --write .",
"db:generate": "dotenvx run -- drizzle-kit generate",
"db:migrate": "dotenvx run -- drizzle-kit migrate"
},
"prettier": {
"useTabs": true,
Expand All @@ -21,38 +23,48 @@
]
},
"dependencies": {
"@lucia-auth/adapter-drizzle": "^1.0.7",
"bits-ui": "^0.21.12",
"bungie-api-ts": "^5.1.0",
"clsx": "^2.1.1",
"dayjs": "^1.11.11",
"drizzle-orm": "^0.31.2",
"lucia": "^3.2.0",
"lucide-svelte": "^0.408.0",
"oslo": "^1.2.0",
"postgres": "^3.4.4",
"svelte-persisted-store": "^0.11.0",
"svelte-radix": "^1.1.0",
"svelte-sonner": "^0.3.25",
"tailwind-merge": "^2.4.0",
"tailwind-variants": "^0.2.1"
},
"devDependencies": {
"@dotenvx/dotenvx": "^0.44.4",
"@svelte-put/inline-svg": "4.0.0-next.2",
"@sveltejs/adapter-auto": "^3.2.2",
"@sveltejs/adapter-vercel": "^5.4.1",
"@sveltejs/kit": "^2.5.18",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@types/eslint": "^8.56.10",
"@types/node": "^20.14.2",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
"autoprefixer": "^10.4.19",
"eslint": "^9.6.0",
"drizzle-kit": "^0.22.7",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.42.0",
"eslint": "^9.6.0",
"postcss": "^8.4.39",
"prettier": "^3.3.2",
"prettier-plugin-svelte": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.6.5",
"svelte": "5.0.0-next.182",
"prettier": "^3.3.2",
"svelte-check": "^3.8.4",
"svelte": "5.0.0-next.182",
"tailwindcss": "^3.4.4",
"tslib": "^2.6.3",
"typescript": "^5.5.3",
"vite-plugin-mkcert": "^1.17.5",
"vite": "^5.3.3"
}
}
Loading

0 comments on commit 8ffd3a5

Please sign in to comment.