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 26, 2023
1 parent 5e61768 commit 78df776
Show file tree
Hide file tree
Showing 40 changed files with 2,354 additions and 756 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.14.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=
18 changes: 18 additions & 0 deletions packages/api/migrations/0002_crazy_post.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE `Session` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`active_expires` blob NOT NULL,
`idle_expires` blob 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 INDEX `idx_session_userId` ON `Session` (`user_id`);--> statement-breakpoint
CREATE INDEX `idx_userKey_userId` ON `UserKey` (`user_id`);
251 changes: 251 additions & 0 deletions packages/api/migrations/meta/0002_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
{
"version": "5",
"dialect": "sqlite",
"id": "d867a35d-ab17-4c90-acb4-0db1ae273122",
"prevId": "19d05176-7733-4654-b24f-799d3fddc19c",
"tables": {
"Car": {
"name": "Car",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"make": {
"name": "make",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"model": {
"name": "model",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"year": {
"name": "year",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"color": {
"name": "color",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"price": {
"name": "price",
"type": "real",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"mileage": {
"name": "mileage",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"fuelType": {
"name": "fuelType",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"transmission": {
"name": "transmission",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"Session": {
"name": "Session",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"active_expires": {
"name": "active_expires",
"type": "blob",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"idle_expires": {
"name": "idle_expires",
"type": "blob",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"idx_session_userId": {
"name": "idx_session_userId",
"columns": [
"user_id"
],
"isUnique": false
}
},
"foreignKeys": {
"Session_user_id_User_id_fk": {
"name": "Session_user_id_User_id_fk",
"tableFrom": "Session",
"tableTo": "User",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"Test": {
"name": "Test",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"UserKey": {
"name": "UserKey",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"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
},
"created_at": {
"name": "created_at",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "CURRENT_TIMESTAMP"
}
},
"indexes": {
"idx_userKey_userId": {
"name": "idx_userKey_userId",
"columns": [
"user_id"
],
"isUnique": false
}
},
"foreignKeys": {
"UserKey_user_id_User_id_fk": {
"name": "UserKey_user_id_User_id_fk",
"tableFrom": "UserKey",
"tableTo": "User",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"User": {
"name": "User",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
}
}
7 changes: 7 additions & 0 deletions packages/api/migrations/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
"when": 1694824497981,
"tag": "0001_worried_gamma_corps",
"breakpoints": true
},
{
"idx": 2,
"version": "5",
"when": 1698253799463,
"tag": "0002_crazy_post",
"breakpoints": true
}
]
}
10 changes: 6 additions & 4 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@
},
"dependencies": {
"@hono/trpc-server": "^0.1.0",
"@libsql/client": "^0.3.5",
"@lucia-auth/adapter-sqlite": "^2.0.1",
"@lucia-auth/oauth": "^3.3.1",
"@trpc/server": "^10.41.0",
"@tsndr/cloudflare-worker-jwt": "^2.2.5",
"drizzle-orm": "^0.28.6",
"drizzle-orm": "beta",
"drizzle-valibot": "^0.1.1",
"hono": "^3.8.1",
"lucia": "^2.7.2",
"superjson": "^1.13.3",
"valibot": "^0.17.1"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20231016.0",
"better-sqlite3": "^8.7.0",
"dotenv-cli": "^7.3.0",
"drizzle-kit": "^0.19.13",
"eslint": "^8.51.0",
"typescript": "^5.2.2",
"wrangler": "3.6.0"
"typescript": "^5.2.2"
}
}
26 changes: 26 additions & 0 deletions packages/api/src/app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// <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 LuciaHono {
type Auth = import('./src/auth/hono').Auth
type DatabaseUserAttributes = DBAttributes
type DatabaseSessionAttributes = {}
}

declare namespace LuciaNext {
type Auth = import('./src/auth/next').Auth
type DatabaseUserAttributes = DBAttributes
type DatabaseSessionAttributes = {}
}

declare namespace Lucia {
type Auth = import('./src/auth/shared').Auth
type DatabaseUserAttributes = DBAttributes
type DatabaseSessionAttributes = {}
}
Loading

0 comments on commit 78df776

Please sign in to comment.