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

feature: Backend #41

Draft
wants to merge 59 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
bb5e87e
feat(db): add database
alexfriesen Dec 20, 2024
844feda
feat(database): add db schema
alexfriesen Jan 14, 2025
e35b36e
feature(database): add user credential schema
alexfriesen Jan 14, 2025
ec18c35
perf(api): optimize db schema
alexfriesen Jan 14, 2025
b67a0f1
refactor: move to correct folder
alexfriesen Jan 14, 2025
3cd9697
feat(db): add database
alexfriesen Dec 20, 2024
6e9db74
feat(auth): add webauthn auth
alexfriesen Jan 8, 2025
9be8e16
fix(auth): handle potential undefined value
alexfriesen Jan 8, 2025
8a6eec2
feat(auth): improve db queries
alexfriesen Jan 9, 2025
56b111a
feat(auth): remove db session
alexfriesen Jan 9, 2025
a68bbd8
feat(auth): add auth challenges
alexfriesen Jan 14, 2025
338b12f
feat(auth): simplify user
alexfriesen Jan 14, 2025
cae4b4a
feat(database): add initial migration
alexfriesen Jan 14, 2025
8dc4def
Merge pull request #43 from alexfriesen/feature/auth
alexfriesen Jan 14, 2025
2c0916b
feat(mailer): add basic mailer
alexfriesen Jan 15, 2025
e8b8b51
feat(mailer): add welcome mail
alexfriesen Jan 16, 2025
0033c12
Merge pull request #45 from alexfriesen/feature/send-mails
alexfriesen Jan 16, 2025
3783941
chore(deps): update deps
alexfriesen Jan 23, 2025
f965362
conf: remove prerender
alexfriesen Jan 23, 2025
7ceb4dd
feat(user): implement user store
alexfriesen Jan 23, 2025
4869a97
feat(user): verify email workflow
alexfriesen Jan 23, 2025
5efea08
chore: update deps
alexfriesen Jan 29, 2025
e1207bc
refactor: move db schema to libs
alexfriesen Jan 29, 2025
c8ac088
feature(organisations): add organisations
alexfriesen Jan 29, 2025
c77bdf6
fix: remove unused import
alexfriesen Feb 1, 2025
a8e8759
feat(organisation): finalize invite & join logic
alexfriesen Feb 1, 2025
d8eeb24
fix(organisation): move to user route after successful join
alexfriesen Feb 2, 2025
cffe11f
fix(organisation): automatically set current organisation
alexfriesen Feb 2, 2025
444a0a5
chore(all): update deps
alexfriesen Feb 2, 2025
eab5e74
ci(zeity): disable broken typecheck
alexfriesen Feb 2, 2025
7af26a7
chore: update deps
alexfriesen Feb 5, 2025
2aba693
ci: use pnpm setup action
alexfriesen Feb 6, 2025
5f88206
chore: update deps
alexfriesen Feb 6, 2025
db2d0be
feat(db): add database
alexfriesen Dec 20, 2024
414c878
feat(database): add db schema
alexfriesen Jan 14, 2025
2884ed5
feature(database): add user credential schema
alexfriesen Jan 14, 2025
166adab
perf(api): optimize db schema
alexfriesen Jan 14, 2025
537ef24
refactor: move to correct folder
alexfriesen Jan 14, 2025
f2f972f
feat(auth): add webauthn auth
alexfriesen Jan 8, 2025
efd7463
fix(auth): handle potential undefined value
alexfriesen Jan 8, 2025
7126f8c
feat(auth): improve db queries
alexfriesen Jan 9, 2025
9310e10
feat(auth): remove db session
alexfriesen Jan 9, 2025
5800a33
feat(auth): add auth challenges
alexfriesen Jan 14, 2025
187d29b
feat(auth): simplify user
alexfriesen Jan 14, 2025
771e93a
feat(database): add initial migration
alexfriesen Jan 14, 2025
8f7a619
feat(mailer): add basic mailer
alexfriesen Jan 15, 2025
f790ed8
feat(mailer): add welcome mail
alexfriesen Jan 16, 2025
05685af
conf: remove prerender
alexfriesen Jan 23, 2025
af5e8c1
feat(user): implement user store
alexfriesen Jan 23, 2025
7939ff5
feat(user): verify email workflow
alexfriesen Jan 23, 2025
76abee4
chore: update deps
alexfriesen Jan 29, 2025
13be7cc
refactor: move db schema to libs
alexfriesen Jan 29, 2025
b7787fd
refactor(mailer): use nodemailer
alexfriesen Feb 19, 2025
a14b732
fix: types
alexfriesen Feb 20, 2025
e8451b1
Merge branch 'main' into backend
alexfriesen Feb 21, 2025
fcf0475
Merge branch 'main' into backend
alexfriesen Feb 23, 2025
4aac7fd
Merge branch 'backend' into feat/organisations
alexfriesen Feb 23, 2025
5647469
fix: downgrade tailwind
alexfriesen Feb 24, 2025
a95583e
Merge pull request #49 from alexfriesen/feat/organisations
alexfriesen Feb 24, 2025
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
Prev Previous commit
Next Next commit
feat(database): add initial migration
alexfriesen committed Jan 14, 2025
commit cae4b4a32dc696eca0d5001855279a8d02ee30e4
6 changes: 2 additions & 4 deletions apps/zeity/server/database/common.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { timestamp } from 'drizzle-orm/pg-core';

export const timestampColumns = () => ({
createdAt: timestamp('created_at', { mode: 'date', withTimezone: true })
.notNull()
.defaultNow(),
updatedAt: timestamp('updated_at', { mode: 'date', withTimezone: true })
createdAt: timestamp('created_at', { mode: 'date' }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { mode: 'date' })
.notNull()
.$onUpdate(() => new Date()),
});
79 changes: 79 additions & 0 deletions apps/zeity/server/database/migrations/0000_initial.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
CREATE TABLE "auth_challenge" (
"id" text PRIMARY KEY NOT NULL,
"challenge" text NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "organisationMember" (
"user_id" uuid NOT NULL,
"organisation_id" uuid NOT NULL,
"role" varchar(10) NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp NOT NULL,
CONSTRAINT "organisationMember_user_id_organisation_id_pk" PRIMARY KEY("user_id","organisation_id")
);
--> statement-breakpoint
CREATE TABLE "organisation" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"name" varchar(150) NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp NOT NULL
);
--> statement-breakpoint
CREATE TABLE "project" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"name" varchar(150) NOT NULL,
"notes" text DEFAULT '' NOT NULL,
"organisation_id" uuid NOT NULL,
"user_id" uuid NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp NOT NULL
);
--> statement-breakpoint
CREATE TABLE "time" (
"id" serial PRIMARY KEY NOT NULL,
"start" timestamp with time zone NOT NULL,
"end" timestamp with time zone NOT NULL,
"duration" integer NOT NULL,
"notes" text DEFAULT '' NOT NULL,
"project_id" uuid,
"organisation_id" uuid NOT NULL,
"user_id" uuid NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp NOT NULL
);
--> statement-breakpoint
CREATE TABLE "user_credential" (
"id" text NOT NULL,
"user_id" uuid NOT NULL,
"public_key" text NOT NULL,
"counter" integer NOT NULL,
"backed_up" boolean NOT NULL,
"transports" jsonb NOT NULL,
CONSTRAINT "user_credential_user_id_id_pk" PRIMARY KEY("user_id","id"),
CONSTRAINT "user_credential_id_unique" UNIQUE("id")
);
--> statement-breakpoint
CREATE TABLE "user" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"name" text NOT NULL,
"email" text NOT NULL,
"email_verified" timestamp with time zone,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp NOT NULL,
CONSTRAINT "user_email_unique" UNIQUE("email")
);
--> statement-breakpoint
ALTER TABLE "organisationMember" ADD CONSTRAINT "organisationMember_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "organisationMember" ADD CONSTRAINT "organisationMember_organisation_id_organisation_id_fk" FOREIGN KEY ("organisation_id") REFERENCES "public"."organisation"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "project" ADD CONSTRAINT "project_organisation_id_organisation_id_fk" FOREIGN KEY ("organisation_id") REFERENCES "public"."organisation"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "project" ADD CONSTRAINT "project_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "time" ADD CONSTRAINT "time_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "time" ADD CONSTRAINT "time_organisation_id_organisation_id_fk" FOREIGN KEY ("organisation_id") REFERENCES "public"."organisation"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "time" ADD CONSTRAINT "time_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "user_credential" ADD CONSTRAINT "user_credential_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "organisation_name_index" ON "organisation" USING btree ("name");--> statement-breakpoint
CREATE INDEX "name_idx" ON "project" USING btree ("name");--> statement-breakpoint
CREATE INDEX "time_start_index" ON "time" USING btree ("start");--> statement-breakpoint
CREATE INDEX "time_end_index" ON "time" USING btree ("end");--> statement-breakpoint
CREATE UNIQUE INDEX "user_email_index" ON "user" USING btree ("email");
Loading