Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- "**"

permissions:
contents: write
pull-requests: write
id-token: write

jobs:
lint:
uses: listee-dev/listee-ci/.github/workflows/lint.yml@main

typecheck:
uses: listee-dev/listee-ci/.github/workflows/typecheck.yml@main
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
34 changes: 34 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["**", "!node_modules", "!.next", "!dist", "!build", "!drizzle"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"domains": {
"next": "recommended",
"react": "recommended"
}
},
"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
295 changes: 295 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { schemaPath } from "@listee/db";
import { loadEnvConfig } from "@next/env";
import { defineConfig } from "drizzle-kit";

loadEnvConfig(process.cwd());

const databaseUrl = process.env.POSTGRES_URL;

if (databaseUrl === undefined || databaseUrl.length === 0) {
throw new Error("POSTGRES_URL is not set.");
}

export default defineConfig({
dialect: "postgresql",
schema: schemaPath,
out: "./drizzle",
dbCredentials: {
url: databaseUrl,
},
});
92 changes: 92 additions & 0 deletions drizzle/0000_gigantic_colleen_wing.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
CREATE TABLE "categories" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"name" text NOT NULL,
"kind" text NOT NULL,
"created_by" uuid NOT NULL,
"updated_by" uuid NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "categories" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE "profiles" (
"id" uuid PRIMARY KEY NOT NULL,
"email" text NOT NULL,
"name" text,
"default_category_id" uuid,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "profiles_email_unique" UNIQUE("email")
);
--> statement-breakpoint
ALTER TABLE "profiles" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE "tasks" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"name" text NOT NULL,
"description" text,
"is_checked" boolean DEFAULT false NOT NULL,
"category_id" uuid NOT NULL,
"created_by" uuid NOT NULL,
"updated_by" uuid NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "tasks" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
ALTER TABLE "categories" ADD CONSTRAINT "categories_created_by_profiles_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."profiles"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "categories" ADD CONSTRAINT "categories_updated_by_profiles_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."profiles"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "tasks" ADD CONSTRAINT "tasks_category_id_categories_id_fk" FOREIGN KEY ("category_id") REFERENCES "public"."categories"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "tasks" ADD CONSTRAINT "tasks_created_by_profiles_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."profiles"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "tasks" ADD CONSTRAINT "tasks_updated_by_profiles_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."profiles"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
CREATE UNIQUE INDEX "categories_system_name_idx" ON "categories" USING btree ("created_by","name") WHERE "categories"."kind" = 'system';--> statement-breakpoint
CREATE POLICY "Users can view their categories" ON "categories" AS PERMISSIVE FOR SELECT TO "authenticated" USING ("categories"."created_by" = (select auth.uid()));--> statement-breakpoint
CREATE POLICY "Users can insert categories" ON "categories" AS PERMISSIVE FOR INSERT TO "authenticated" WITH CHECK ("categories"."created_by" = (select auth.uid()));--> statement-breakpoint
CREATE POLICY "Users can update their categories" ON "categories" AS PERMISSIVE FOR UPDATE TO "authenticated" USING ("categories"."created_by" = (select auth.uid())) WITH CHECK ("categories"."created_by" = (select auth.uid()));--> statement-breakpoint
CREATE POLICY "Users can delete their categories" ON "categories" AS PERMISSIVE FOR DELETE TO "authenticated" USING ("categories"."created_by" = (select auth.uid()));--> statement-breakpoint
CREATE POLICY "Users can view their profile" ON "profiles" AS PERMISSIVE FOR SELECT TO "authenticated" USING ("profiles"."id" = (select auth.uid()));--> statement-breakpoint
CREATE POLICY "Users can insert their profile" ON "profiles" AS PERMISSIVE FOR INSERT TO "authenticated" WITH CHECK ("profiles"."id" = (select auth.uid()));--> statement-breakpoint
CREATE POLICY "Users can update their profile" ON "profiles" AS PERMISSIVE FOR UPDATE TO "authenticated" USING ("profiles"."id" = (select auth.uid())) WITH CHECK ("profiles"."id" = (select auth.uid()));--> statement-breakpoint
CREATE POLICY "Users can view their tasks" ON "tasks" AS PERMISSIVE FOR SELECT TO "authenticated" USING (
"tasks"."created_by" = (select auth.uid())
OR EXISTS (
SELECT 1
FROM "categories"
WHERE "categories"."id" = "tasks"."category_id"
AND "categories"."created_by" = (select auth.uid())
)
);--> statement-breakpoint
CREATE POLICY "Users can insert tasks in their categories" ON "tasks" AS PERMISSIVE FOR INSERT TO "authenticated" WITH CHECK (
"tasks"."created_by" = (select auth.uid())
OR EXISTS (
SELECT 1
FROM "categories"
WHERE "categories"."id" = "tasks"."category_id"
AND "categories"."created_by" = (select auth.uid())
)
);--> statement-breakpoint
CREATE POLICY "Users can update their tasks" ON "tasks" AS PERMISSIVE FOR UPDATE TO "authenticated" USING (
"tasks"."created_by" = (select auth.uid())
OR EXISTS (
SELECT 1
FROM "categories"
WHERE "categories"."id" = "tasks"."category_id"
AND "categories"."created_by" = (select auth.uid())
)
) WITH CHECK (
"tasks"."created_by" = (select auth.uid())
OR EXISTS (
SELECT 1
FROM "categories"
WHERE "categories"."id" = "tasks"."category_id"
AND "categories"."created_by" = (select auth.uid())
)
);--> statement-breakpoint
CREATE POLICY "Users can delete their tasks" ON "tasks" AS PERMISSIVE FOR DELETE TO "authenticated" USING (
"tasks"."created_by" = (select auth.uid())
OR EXISTS (
SELECT 1
FROM "categories"
WHERE "categories"."id" = "tasks"."category_id"
AND "categories"."created_by" = (select auth.uid())
)
);
6 changes: 6 additions & 0 deletions drizzle/0001_lying_firebrand.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE INDEX "idx_categories_created_by" ON "categories" USING btree ("created_by");--> statement-breakpoint
CREATE INDEX "idx_categories_updated_by" ON "categories" USING btree ("updated_by");--> statement-breakpoint
CREATE INDEX "idx_profiles_default_category_id" ON "profiles" USING btree ("default_category_id");--> statement-breakpoint
CREATE INDEX "idx_tasks_category_id" ON "tasks" USING btree ("category_id");--> statement-breakpoint
CREATE INDEX "idx_tasks_created_by" ON "tasks" USING btree ("created_by");--> statement-breakpoint
CREATE INDEX "idx_tasks_updated_by" ON "tasks" USING btree ("updated_by");
1 change: 1 addition & 0 deletions drizzle/0002_gigantic_starbolt.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "profiles" ADD CONSTRAINT "profiles_default_category_id_categories_id_fk" FOREIGN KEY ("default_category_id") REFERENCES "public"."categories"("id") ON DELETE restrict ON UPDATE no action;
Loading