Skip to content

Commit 48f6306

Browse files
authored
Merge pull request #2 from Rykuno/feature/prisma
Drizzle/BetterAuth/Storage rework
2 parents 1b9d32b + 413fec4 commit 48f6306

File tree

169 files changed

+23147
-21203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+23147
-21203
lines changed

.github/workflows/node.js.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
node-version: [24.4.1]
18+
node-version: [25.2.1]
1919
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2020

2121
steps:
@@ -25,7 +25,7 @@ jobs:
2525
- name: ⎔ Setup pnpm
2626
uses: pnpm/action-setup@v4
2727
with:
28-
version: 10.13.1
28+
version: 10.27.0
2929

3030
- name: Setup Node.js
3131
uses: actions/setup-node@v4
@@ -41,6 +41,6 @@ jobs:
4141

4242
- name: Lint
4343
run: pnpm lint
44-
44+
4545
- name: Build project
4646
run: pnpm build
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../..

AGENTS.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Agent Guidelines
2+
3+
## Project Structure
4+
5+
- **Backend**: `apps/api/` - NestJS with Drizzle ORM
6+
- **Frontend**: `apps/web/` - TanStack Start
7+
- **Shared**: `packages/typescript-config/` - Shared TypeScript configs
8+
9+
## Frontend
10+
11+
### Routing (TanStack Start)
12+
13+
- Use Tanstack Start best practices
14+
15+
### Data Fetching (TanStack Query)
16+
17+
- Query keys: `['resource', id, 'sub-resource']`
18+
- Use `invalidateQueries()` without parameters
19+
20+
### Forms (TanStack Forms)
21+
22+
- Use `useForm()`, ShadCN Field components (`Field`, `FieldLabel`, `FieldError`), `form.useField()` for fields
23+
24+
### UI Components (ShadCN + BaseUI)
25+
26+
- Components: `apps/web/src/components/ui/` - ShadCN
27+
- Prefer BaseUI primitives over raw html (`@base-ui/react`)
28+
- Utils: `apps/web/src/lib/utils.ts` - `cn()` helper
29+
- Tailwind CSS with ShadCN design tokens
30+
31+
### Type Safety
32+
33+
- E2E types: `apps/api/generated/openapi.d.ts` (auto-generated)
34+
35+
### Creating Routes/Components
36+
37+
- Routes: `apps/web/src/routes/{path}.tsx` with `createFileRoute()`
38+
- Components: `apps/web/src/components/` using ShadCN UI + `cn()`
39+
40+
## Backend
41+
42+
### Database
43+
44+
- Schema: `apps/api/src/databases/drizzle.schema.ts`
45+
- Tables: `apps/api/src/databases/tables/*.table.ts`
46+
- Utils: `apps/api/src/databases/drizzle.utils.ts`
47+
- Provider: `apps/api/src/databases/drizzle.provider.ts`
48+
49+
### Authentication
50+
51+
- Provider: `apps/api/src/auth/better-auth.provider.ts`
52+
- Guard: `apps/api/src/auth/guards/auth.guard.ts`
53+
- Decorators: `@Auth()`, `@ActiveUser()`, `@ActiveSession()`
54+
55+
### Transactions
56+
57+
- Use `@Transactional()` decorator
58+
- Inject `TransactionHost<DrizzleTransactionClient>`
59+
- Don't manually wrap with `tx.transaction()`
60+
61+
### Services
62+
63+
- Providers for external clients (Better Auth, Drizzle)
64+
- Services handle business logic
65+
- Export providers with `Inject*()` helpers
66+
67+
### Error Handling
68+
69+
- Use NestJS exceptions (`NotFoundException`, `UnauthorizedException`, etc.)
70+
71+
### Type Safety
72+
73+
- E2E types: `apps/api/generated/openapi.d.ts` (auto-generated)
74+
- Use `Serialize` decorator for DTO transformation
75+
76+
### Creating Tables
77+
78+
1. Create `apps/api/src/databases/tables/{name}.table.ts`
79+
2. Export from `drizzle.schema.ts`
80+
3. Add relations in `drizzle.relations.ts`
81+
82+
## Important Notes
83+
84+
- Don't nest transactions - use `@Transactional()` decorator
85+
- Avoid `as any` - use proper types or `as` with specific types

apps/api/.env.example

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
# app
2-
PORT=8000
3-
BASE_URL=http://localhost:8000
4-
NODE_ENV=development
2+
APP_NAME=SojuStack
3+
APP_PORT=8000
4+
APP_URL=http://localhost:8000
5+
APP_WEB_URL=http://localhost:3000
56

6-
# better-auth
7+
# auth
78
AUTH_SECRET=CHANGE_THIS_FOR_PROD
89

9-
# databases
10-
POSTGRES_URL=postgres://postgres:postgres@localhost:5432/postgres
11-
REDIS_URL=redis://localhost:6379
10+
# database
11+
DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres
12+
13+
# cache
14+
CACHE_URL=redis://localhost:6379
1215

1316
# email
14-
EMAIL_DOMAIN=example.com
17+
MAIL_DOMAIN=example.com
1518

1619
# storage
17-
STORAGE_HOST=localhost
18-
STORAGE_PORT=9000
19-
STORAGE_ACCESS_KEY=user
20-
STORAGE_SECRET_KEY=password
20+
STORAGE_URL=http://localhost:9000
21+
STORAGE_REGION=us-east-1
22+
STORAGE_ACCESS_KEY=admin
23+
STORAGE_SECRET_KEY=admin

apps/api/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@ pids
5454

5555
# Diagnostic reports (https://nodejs.org/api/report.html)
5656
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
57+
.nestjs_repl_history
58+
generated

apps/api/.nestjs_repl_history

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$(AppService).getHello()

apps/api/drizzle.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// @ts-nocheck
2+
import 'dotenv/config';
3+
import { defineConfig } from 'drizzle-kit';
4+
5+
export default defineConfig({
6+
dialect: 'postgresql',
7+
schema: './src/databases/drizzle.schema.ts',
8+
out: './src/databases/migrations',
9+
dbCredentials: {
10+
url: process.env['DATABASE_URL']!,
11+
},
12+
});

0 commit comments

Comments
 (0)