-
Notifications
You must be signed in to change notification settings - Fork 0
Drizzle/BetterAuth/Storage rework #2
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
Changes from all commits
9e72cf9
63e2671
11f1aee
5cf4962
00791b0
2afc512
ab0c3e3
ab302da
21ec206
884b355
a143714
a26fda9
18d90de
ebf0ed6
5f231d6
067315b
413fec4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../.. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Agent Guidelines | ||
|
|
||
| ## Project Structure | ||
|
|
||
| - **Backend**: `apps/api/` - NestJS with Drizzle ORM | ||
| - **Frontend**: `apps/web/` - TanStack Start | ||
| - **Shared**: `packages/typescript-config/` - Shared TypeScript configs | ||
|
|
||
| ## Frontend | ||
|
|
||
| ### Routing (TanStack Start) | ||
|
|
||
| - Use Tanstack Start best practices | ||
|
|
||
| ### Data Fetching (TanStack Query) | ||
|
|
||
| - Query keys: `['resource', id, 'sub-resource']` | ||
| - Use `invalidateQueries()` without parameters | ||
|
|
||
| ### Forms (TanStack Forms) | ||
|
|
||
| - Use `useForm()`, ShadCN Field components (`Field`, `FieldLabel`, `FieldError`), `form.useField()` for fields | ||
|
|
||
| ### UI Components (ShadCN + BaseUI) | ||
|
|
||
| - Components: `apps/web/src/components/ui/` - ShadCN | ||
| - Prefer BaseUI primitives over raw html (`@base-ui/react`) | ||
| - Utils: `apps/web/src/lib/utils.ts` - `cn()` helper | ||
| - Tailwind CSS with ShadCN design tokens | ||
|
|
||
| ### Type Safety | ||
|
|
||
| - E2E types: `apps/api/generated/openapi.d.ts` (auto-generated) | ||
|
|
||
| ### Creating Routes/Components | ||
|
|
||
| - Routes: `apps/web/src/routes/{path}.tsx` with `createFileRoute()` | ||
| - Components: `apps/web/src/components/` using ShadCN UI + `cn()` | ||
|
|
||
| ## Backend | ||
|
|
||
| ### Database | ||
|
|
||
| - Schema: `apps/api/src/databases/drizzle.schema.ts` | ||
| - Tables: `apps/api/src/databases/tables/*.table.ts` | ||
| - Utils: `apps/api/src/databases/drizzle.utils.ts` | ||
| - Provider: `apps/api/src/databases/drizzle.provider.ts` | ||
|
|
||
| ### Authentication | ||
|
|
||
| - Provider: `apps/api/src/auth/better-auth.provider.ts` | ||
| - Guard: `apps/api/src/auth/guards/auth.guard.ts` | ||
| - Decorators: `@Auth()`, `@ActiveUser()`, `@ActiveSession()` | ||
|
|
||
| ### Transactions | ||
|
|
||
| - Use `@Transactional()` decorator | ||
| - Inject `TransactionHost<DrizzleTransactionClient>` | ||
| - Don't manually wrap with `tx.transaction()` | ||
|
|
||
| ### Services | ||
|
|
||
| - Providers for external clients (Better Auth, Drizzle) | ||
| - Services handle business logic | ||
| - Export providers with `Inject*()` helpers | ||
|
|
||
| ### Error Handling | ||
|
|
||
| - Use NestJS exceptions (`NotFoundException`, `UnauthorizedException`, etc.) | ||
|
|
||
| ### Type Safety | ||
|
|
||
| - E2E types: `apps/api/generated/openapi.d.ts` (auto-generated) | ||
| - Use `Serialize` decorator for DTO transformation | ||
|
|
||
| ### Creating Tables | ||
|
|
||
| 1. Create `apps/api/src/databases/tables/{name}.table.ts` | ||
| 2. Export from `drizzle.schema.ts` | ||
| 3. Add relations in `drizzle.relations.ts` | ||
|
|
||
| ## Important Notes | ||
|
|
||
| - Don't nest transactions - use `@Transactional()` decorator | ||
| - Avoid `as any` - use proper types or `as` with specific types |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,23 @@ | ||
| # app | ||
| PORT=8000 | ||
| BASE_URL=http://localhost:8000 | ||
| NODE_ENV=development | ||
| APP_NAME=SojuStack | ||
| APP_PORT=8000 | ||
| APP_URL=http://localhost:8000 | ||
| APP_WEB_URL=http://localhost:3000 | ||
|
|
||
| # better-auth | ||
| # auth | ||
| AUTH_SECRET=CHANGE_THIS_FOR_PROD | ||
|
|
||
| # databases | ||
| POSTGRES_URL=postgres://postgres:postgres@localhost:5432/postgres | ||
| REDIS_URL=redis://localhost:6379 | ||
| # database | ||
| DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres | ||
|
|
||
| # cache | ||
| CACHE_URL=redis://localhost:6379 | ||
|
|
||
| EMAIL_DOMAIN=example.com | ||
| MAIL_DOMAIN=example.com | ||
|
|
||
| # storage | ||
| STORAGE_HOST=localhost | ||
| STORAGE_PORT=9000 | ||
| STORAGE_ACCESS_KEY=user | ||
| STORAGE_SECRET_KEY=password | ||
| STORAGE_URL=http://localhost:9000 | ||
| STORAGE_REGION=us-east-1 | ||
| STORAGE_ACCESS_KEY=admin | ||
| STORAGE_SECRET_KEY=admin |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| $(AppService).getHello() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. REPL history file accidentally committed to repositoryThe |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // @ts-nocheck | ||
| import 'dotenv/config'; | ||
| import { defineConfig } from 'drizzle-kit'; | ||
|
|
||
| export default defineConfig({ | ||
| dialect: 'postgresql', | ||
| schema: './src/databases/drizzle.schema.ts', | ||
| out: './src/databases/migrations', | ||
| dbCredentials: { | ||
| url: process.env['DATABASE_URL']!, | ||
| }, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internal pnpm store file accidentally committed to repository
A
.pnpm-storefile was committed to the repository. This is internal pnpm package manager storage that contains a symlink path (../../..) and should not be tracked in version control. This directory should be added to.gitignore.