Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding in an auth layer for to prep for viewing services #39

Merged
merged 32 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
eab923e
chore: update migration snapshots
SeanCassiere Jun 25, 2024
1e687ac
feat: update database schema and generate the migration files
SeanCassiere Jun 25, 2024
3a03c58
feat: correct database migration
SeanCassiere Jun 25, 2024
2261caf
feat: lucia configuration
SeanCassiere Jun 25, 2024
56d93a3
feat: correctly mapping the many-to-many relations
SeanCassiere Jun 25, 2024
61fe515
feat: better migration I think
SeanCassiere Jun 25, 2024
ff7fa9c
feat: add auth
SeanCassiere Jun 25, 2024
24fa1aa
feat: allow for tenants to have multiple services
SeanCassiere Jun 25, 2024
a8a3de1
feat: redo the migration allowing for a workspace id to be set
SeanCassiere Jun 25, 2024
7661db0
feat: migrations
SeanCassiere Jun 25, 2024
c17763d
feat: basic working auth
SeanCassiere Jun 25, 2024
2e0ea66
feat: detect the key type
SeanCassiere Jun 25, 2024
0813878
chore: update the .env.example
SeanCassiere Jun 25, 2024
aa3e7bc
chore: rename to `key_prefix`
SeanCassiere Jun 25, 2024
4c4a033
feat: restructure the directories for an app
SeanCassiere Jun 25, 2024
3576716
feat: ui should be separate
SeanCassiere Jun 26, 2024
68a7327
refactor: folder rename
SeanCassiere Jun 30, 2024
10b7260
chore: tsx
SeanCassiere Jun 30, 2024
f6b34b1
refactor: esm and jsx
SeanCassiere Jun 30, 2024
8e53e48
feat: basis
SeanCassiere Jun 30, 2024
33adffc
chore: typing
SeanCassiere Jun 30, 2024
cce235c
chore: meta tags
SeanCassiere Jun 30, 2024
a7933dd
feat: actually getting something that resembles ui
SeanCassiere Jun 30, 2024
cf9830a
chore: update drizzle config to point at the right schema file
SeanCassiere Jun 30, 2024
9d220ed
feat: basic routing for viewing
SeanCassiere Jun 30, 2024
f56eb64
feat: add dummy pages
SeanCassiere Jun 30, 2024
e693897
chore: bump package.json t 2.3.2
SeanCassiere Jun 30, 2024
c281633
chore: spacing
SeanCassiere Jun 30, 2024
c13553a
chore: bump baseline runtime deps
SeanCassiere Jun 30, 2024
fdfc47a
chore: drizzle-kit
SeanCassiere Jun 30, 2024
cc53f64
chore: remove the migrator script
SeanCassiere Jun 30, 2024
6065e44
chore: set packageManager field to 9.4.0 in the package.json
SeanCassiere Jun 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ DATABASE_URL="postgresql://postgres:postgres@localhost:5432/simple-logging-serve
PORT=4500
DEFAULT_NUM_OF_MONTHS_TO_DELETE=8
SERVER_URI="http://localhost:4500"
FREEZE_DB_WRITES="false"
FREEZE_DB_WRITES="false"

GITHUB_CLIENT_ID="xxxx"
GITHUB_CLIENT_SECRET="xxxx"
2 changes: 1 addition & 1 deletion drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (!DB_URL) {
}

export default defineConfig({
schema: "./src/config/db/schema.ts",
schema: "./src/config/db/schema.mts",
out: "./drizzle",
dialect: "postgresql",
dbCredentials: {
Expand Down
57 changes: 57 additions & 0 deletions drizzle/0003_smart_azazel.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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,
"created_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "tenants" (
"id" text PRIMARY KEY NOT NULL,
"name" text NOT NULL,
"workspace" text NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "tenants_workspace_unique" UNIQUE("workspace")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "users" (
"id" text PRIMARY KEY NOT NULL,
"username" text NOT NULL,
"github_id" text,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "users_github_id_unique" UNIQUE("github_id")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "users_to_tenants" (
"user_id" text NOT NULL,
"tenant_id" text NOT NULL,
CONSTRAINT "users_to_tenants_user_id_tenant_id_pk" PRIMARY KEY("user_id","tenant_id")
);
--> statement-breakpoint
ALTER TABLE "services" ADD COLUMN "tenant_id" text;--> 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 cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "users_to_tenants" ADD CONSTRAINT "users_to_tenants_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "users_to_tenants" ADD CONSTRAINT "users_to_tenants_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "services" ADD CONSTRAINT "services_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "service_tenant_idx" ON "services" USING btree ("tenant_id");
62 changes: 44 additions & 18 deletions drizzle/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"version": "5",
"dialect": "pg",
"id": "4c7a7f60-c5a1-472e-a4d2-d6e324943bb3",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
"tables": {
"logs": {
"public.logs": {
"name": "logs",
"schema": "",
"columns": {
Expand Down Expand Up @@ -66,25 +64,40 @@
},
"indexes": {
"log_created_at_idx": {
"columns": [
{
"expression": "created_at",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"with": {},
"name": "log_created_at_idx",
"columns": ["created_at"],
"isUnique": false
"isUnique": false,
"method": "btree",
"concurrently": false
}
},
"foreignKeys": {
"logs_service_id_services_id_fk": {
"name": "logs_service_id_services_id_fk",
"tableFrom": "logs",
"columnsFrom": [
"service_id"
],
"tableTo": "services",
"columnsFrom": ["service_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "cascade"
"columnsTo": [
"id"
],
"onUpdate": "cascade",
"onDelete": "cascade"
}
},
"compositePrimaryKeys": {}
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"services": {
"public.services": {
"name": "services",
"schema": "",
"columns": {
Expand Down Expand Up @@ -128,13 +141,24 @@
},
"indexes": {
"service_created_at_idx": {
"columns": [
{
"expression": "created_at",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"with": {},
"name": "service_created_at_idx",
"columns": ["created_at"],
"isUnique": false
"isUnique": false,
"method": "btree",
"concurrently": false
}
},
"foreignKeys": {},
"compositePrimaryKeys": {}
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
Expand All @@ -143,5 +167,7 @@
"schemas": {},
"tables": {},
"columns": {}
}
}
},
"id": "4c7a7f60-c5a1-472e-a4d2-d6e324943bb3",
"prevId": "00000000-0000-0000-0000-000000000000"
}
62 changes: 44 additions & 18 deletions drizzle/meta/0001_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"version": "5",
"dialect": "pg",
"id": "19b9ab6a-21fa-4bb0-91c2-2460725df8c5",
"prevId": "4c7a7f60-c5a1-472e-a4d2-d6e324943bb3",
"version": "7",
"dialect": "postgresql",
"tables": {
"logs": {
"public.logs": {
"name": "logs",
"schema": "",
"columns": {
Expand Down Expand Up @@ -66,25 +64,40 @@
},
"indexes": {
"log_created_at_idx": {
"columns": [
{
"expression": "created_at",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"with": {},
"name": "log_created_at_idx",
"columns": ["created_at"],
"isUnique": false
"isUnique": false,
"method": "btree",
"concurrently": false
}
},
"foreignKeys": {
"logs_service_id_services_id_fk": {
"name": "logs_service_id_services_id_fk",
"tableFrom": "logs",
"columnsFrom": [
"service_id"
],
"tableTo": "services",
"columnsFrom": ["service_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "cascade"
"columnsTo": [
"id"
],
"onUpdate": "cascade",
"onDelete": "cascade"
}
},
"compositePrimaryKeys": {}
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"services": {
"public.services": {
"name": "services",
"schema": "",
"columns": {
Expand Down Expand Up @@ -128,13 +141,24 @@
},
"indexes": {
"service_created_at_idx": {
"columns": [
{
"expression": "created_at",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"with": {},
"name": "service_created_at_idx",
"columns": ["created_at"],
"isUnique": false
"isUnique": false,
"method": "btree",
"concurrently": false
}
},
"foreignKeys": {},
"compositePrimaryKeys": {}
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
Expand All @@ -143,5 +167,7 @@
"schemas": {},
"tables": {},
"columns": {}
}
}
},
"id": "19b9ab6a-21fa-4bb0-91c2-2460725df8c5",
"prevId": "4c7a7f60-c5a1-472e-a4d2-d6e324943bb3"
}
Loading