Skip to content

Commit

Permalink
lucia-auth instead of supabase
Browse files Browse the repository at this point in the history
  • Loading branch information
rmarscher committed Oct 27, 2023
1 parent 5e61768 commit bbf38fd
Show file tree
Hide file tree
Showing 41 changed files with 2,637 additions and 765 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
"check-dependency-version-consistency": "^4.1.0",
"cross-env": "^7.0.3",
"eslint": "^8.51.0",
"miniflare": "3.20230922.0",
"node-gyp": "^9.4.0",
"prettier": "^3.0.3",
"react-native-url-polyfill": "^2.0.0",
"turbo": "^1.10.16",
"typescript": "^5.2.2"
"typescript": "^5.2.2",
"wrangler": "3.15.0"
},
"engines": {
"node": ">=18.16.1",
Expand Down
11 changes: 10 additions & 1 deletion packages/api/.dev.vars.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
APP_URL=http://localhost:3000
JWT_VERIFICATION_KEY=
DATABASE_ID=
DATABASE_ID=

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
APPLE_CLIENT_ID=
APPLE_TEAM_ID=
APPLE_KEY_ID=
APPLE_CERTIFICATE=
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
14 changes: 14 additions & 0 deletions packages/api/app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/// <reference types="lucia" />

type DBAttributes = {
// Note, these need to match the database column names,
// so they might need to be snake_case instead of camelCase, for example
// Adjust userToAuthUserAttributes in @t4/api/src/auth to match
email: string | null
}

declare namespace Lucia {
type Auth = import('./src/auth/shared').Auth
type DatabaseUserAttributes = DBAttributes
type DatabaseSessionAttributes = {}
}
30 changes: 30 additions & 0 deletions packages/api/migrations/0002_elite_blackheart.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
CREATE TABLE `Session` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`active_expires` integer NOT NULL,
`idle_expires` integer NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `User`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `UserKey` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`hashed_password` text,
`created_at` text DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (`user_id`) REFERENCES `User`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `VerificationCode` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`code` text NOT NULL,
`expires` integer NOT NULL,
`timeout_until` integer,
`timeout_seconds` integer DEFAULT 0 NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `User`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE INDEX `idx_session_userId` ON `Session` (`user_id`);--> statement-breakpoint
CREATE INDEX `idx_userKey_userId` ON `UserKey` (`user_id`);--> statement-breakpoint
CREATE UNIQUE INDEX `VerificationCode_user_id_unique` ON `VerificationCode` (`user_id`);--> statement-breakpoint
CREATE INDEX `idx_verificationCode_userId` ON `VerificationCode` (`user_id`);
Loading

0 comments on commit bbf38fd

Please sign in to comment.