mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-18 12:09:43 +02:00
style: auto-format codebase with Prettier
Applied formatting to 1487+ files using pnpm format:write - TypeScript/JavaScript files - Svelte components - Astro pages - JSON configs - Markdown docs 13 files still need manual review (Astro JSX comments)
This commit is contained in:
parent
0241f5554c
commit
d36b321d9d
3952 changed files with 661498 additions and 739751 deletions
|
|
@ -1,11 +1,13 @@
|
|||
# PocketBase Development Setup - Implementierungsplan
|
||||
|
||||
## 🎯 Ziel
|
||||
|
||||
Vollständige Trennung von Development und Production Datenbanken, ähnlich wie bei Redis.
|
||||
|
||||
## 📋 Aktuelle Situation
|
||||
|
||||
### Probleme:
|
||||
|
||||
- ❌ Beide Umgebungen nutzen Production DB (`https://pb.ulo.ad`)
|
||||
- ❌ Gefahr von Testdaten in Production
|
||||
- ❌ Keine lokale Entwicklungsumgebung
|
||||
|
|
@ -13,6 +15,7 @@ Vollständige Trennung von Development und Production Datenbanken, ähnlich wie
|
|||
- ❌ Inkonsistente Environment-Variable-Nutzung
|
||||
|
||||
### Vorhandene Ressourcen:
|
||||
|
||||
- ✅ PocketBase Binary bereits in `backend/` vorhanden
|
||||
- ✅ `npm run backend` Script existiert
|
||||
- ✅ Lokale DB-Dateien in `backend/pb_data/`
|
||||
|
|
@ -23,12 +26,14 @@ Vollständige Trennung von Development und Production Datenbanken, ähnlich wie
|
|||
### Phase 1: Lokale PocketBase einrichten (15 Min)
|
||||
|
||||
1. **PocketBase starten**
|
||||
|
||||
```bash
|
||||
cd backend
|
||||
./pocketbase serve
|
||||
```
|
||||
|
||||
- Läuft auf http://localhost:8090
|
||||
- Admin UI: http://localhost:8090/_/
|
||||
- Admin UI: http://localhost:8090/\_/
|
||||
|
||||
2. **Admin Account erstellen**
|
||||
- Beim ersten Start wird Admin-Account angelegt
|
||||
|
|
@ -43,11 +48,12 @@ Vollständige Trennung von Development und Production Datenbanken, ähnlich wie
|
|||
### Phase 2: Environment Variables korrigieren (10 Min)
|
||||
|
||||
1. **.env.development anpassen**
|
||||
|
||||
```env
|
||||
# PocketBase Configuration (Local Development)
|
||||
PUBLIC_POCKETBASE_URL=http://localhost:8090
|
||||
POCKETBASE_URL=http://localhost:8090
|
||||
|
||||
|
||||
# PocketBase Admin (for local development)
|
||||
POCKETBASE_ADMIN_EMAIL=admin@localhost
|
||||
POCKETBASE_ADMIN_PASSWORD=localdevpassword123
|
||||
|
|
@ -63,12 +69,13 @@ Vollständige Trennung von Development und Production Datenbanken, ähnlich wie
|
|||
### Phase 3: Code-Anpassungen (20 Min)
|
||||
|
||||
1. **src/lib/pocketbase.ts**
|
||||
|
||||
```typescript
|
||||
import { dev } from '$app/environment';
|
||||
|
||||
|
||||
// Automatic environment detection
|
||||
const POCKETBASE_URL = import.meta.env.PUBLIC_POCKETBASE_URL ||
|
||||
(dev ? 'http://localhost:8090' : 'https://pb.ulo.ad');
|
||||
const POCKETBASE_URL =
|
||||
import.meta.env.PUBLIC_POCKETBASE_URL || (dev ? 'http://localhost:8090' : 'https://pb.ulo.ad');
|
||||
```
|
||||
|
||||
2. **Hardcoded URLs entfernen**
|
||||
|
|
@ -82,6 +89,7 @@ Vollständige Trennung von Development und Production Datenbanken, ähnlich wie
|
|||
### Phase 4: Daten-Migration (30 Min)
|
||||
|
||||
1. **Test-Daten erstellen**
|
||||
|
||||
```bash
|
||||
# Script für Sample-Daten
|
||||
npm run seed:dev
|
||||
|
|
@ -102,15 +110,16 @@ Vollständige Trennung von Development und Production Datenbanken, ähnlich wie
|
|||
### Phase 5: Development Workflow (10 Min)
|
||||
|
||||
1. **Start-Scripts optimieren**
|
||||
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"dev": "npm run dev:frontend",
|
||||
"dev:frontend": "vite dev",
|
||||
"dev:backend": "cd backend && ./pocketbase serve",
|
||||
"dev:all": "concurrently \"npm:dev:backend\" \"npm:dev:frontend\"",
|
||||
"dev:setup": "npm run dev:backend:setup && npm run dev:seed"
|
||||
}
|
||||
"scripts": {
|
||||
"dev": "npm run dev:frontend",
|
||||
"dev:frontend": "vite dev",
|
||||
"dev:backend": "cd backend && ./pocketbase serve",
|
||||
"dev:all": "concurrently \"npm:dev:backend\" \"npm:dev:frontend\"",
|
||||
"dev:setup": "npm run dev:backend:setup && npm run dev:seed"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
|
@ -121,7 +130,7 @@ Vollständige Trennung von Development und Production Datenbanken, ähnlich wie
|
|||
pocketbase:
|
||||
image: ghcr.io/pocketbase/pocketbase:latest
|
||||
ports:
|
||||
- "8090:8090"
|
||||
- '8090:8090'
|
||||
volumes:
|
||||
- ./backend/pb_data:/pb_data
|
||||
```
|
||||
|
|
@ -150,7 +159,7 @@ Vollständige Trennung von Development und Production Datenbanken, ähnlich wie
|
|||
# 1. Backend starten
|
||||
npm run dev:backend
|
||||
|
||||
# 2. In neuem Terminal: Frontend starten
|
||||
# 2. In neuem Terminal: Frontend starten
|
||||
npm run dev:frontend
|
||||
|
||||
# Oder alles zusammen:
|
||||
|
|
@ -160,29 +169,32 @@ npm run dev:all
|
|||
## ⚠️ Wichtige Überlegungen
|
||||
|
||||
### Daten-Synchronisation
|
||||
|
||||
- **NICHT** Production-Daten lokal spiegeln
|
||||
- Nur Schema/Structure synchronisieren
|
||||
- Test-Daten separat verwalten
|
||||
|
||||
### Secrets Management
|
||||
|
||||
- Lokale Admin-Credentials nur für Dev
|
||||
- Keine Production-Secrets in .env.development
|
||||
- Stripe Test-Keys für lokale Entwicklung
|
||||
|
||||
### Backup Strategy
|
||||
|
||||
- Lokale DB regelmäßig committen? (ohne sensible Daten)
|
||||
- Schema-Änderungen als Migrations tracken
|
||||
- Production Backups separat
|
||||
|
||||
## 📊 Vergleich: Vorher vs Nachher
|
||||
|
||||
| Aspekt | Vorher | Nachher |
|
||||
|--------|---------|---------|
|
||||
| Dev Database | Production (pb.ulo.ad) | Lokal (localhost:8090) |
|
||||
| Test-Daten | In Production! | Isoliert lokal |
|
||||
| Performance | Netzwerk-Latenz | Instant (lokal) |
|
||||
| Sicherheit | Risiko für Prod-Daten | Vollständig getrennt |
|
||||
| Offline-Arbeit | Nicht möglich | Voll funktionsfähig |
|
||||
| Aspekt | Vorher | Nachher |
|
||||
| -------------- | ---------------------- | ---------------------- |
|
||||
| Dev Database | Production (pb.ulo.ad) | Lokal (localhost:8090) |
|
||||
| Test-Daten | In Production! | Isoliert lokal |
|
||||
| Performance | Netzwerk-Latenz | Instant (lokal) |
|
||||
| Sicherheit | Risiko für Prod-Daten | Vollständig getrennt |
|
||||
| Offline-Arbeit | Nicht möglich | Voll funktionsfähig |
|
||||
|
||||
## 🔄 Migration Checkliste
|
||||
|
||||
|
|
@ -210,4 +222,4 @@ npm run dev:all
|
|||
2. Team informieren über Änderungen
|
||||
3. Migration durchführen
|
||||
4. Dokumentation für Team erstellen
|
||||
5. CI/CD anpassen für neue Struktur
|
||||
5. CI/CD anpassen für neue Struktur
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Da der Schema-Import nicht funktioniert (veraltetes Format), musst du die Collec
|
|||
|
||||
## 🎯 Admin Login
|
||||
|
||||
1. Gehe zu: http://localhost:8090/_/
|
||||
1. Gehe zu: http://localhost:8090/\_/
|
||||
2. Login mit:
|
||||
- Email: `till.schneider@memoro.ai`
|
||||
- Password: `p0ck3t-RAJ`
|
||||
|
|
@ -19,21 +19,22 @@ Da der Schema-Import nicht funktioniert (veraltetes Format), musst du die Collec
|
|||
|
||||
**Fields hinzufügen (+ New field):**
|
||||
|
||||
| Field Name | Type | Required | Options |
|
||||
|------------|------|----------|---------|
|
||||
| `short_code` | text | ✅ | Unique: ✅, Min: 3, Max: 50 |
|
||||
| `original_url` | url | ✅ | - |
|
||||
| `title` | text | ❌ | Max: 200 |
|
||||
| `description` | text | ❌ | Max: 500 |
|
||||
| `user_id` | relation | ❌ | Collection: users, Max select: 1, Cascade delete: ✅ |
|
||||
| `is_active` | bool | ❌ | - |
|
||||
| `password` | text | ❌ | - |
|
||||
| `max_clicks` | number | ❌ | Min: 0 |
|
||||
| `expires_at` | date | ❌ | - |
|
||||
| `click_count` | number | ❌ | - |
|
||||
| `tags` | json | ❌ | - |
|
||||
| Field Name | Type | Required | Options |
|
||||
| -------------- | -------- | -------- | ---------------------------------------------------- |
|
||||
| `short_code` | text | ✅ | Unique: ✅, Min: 3, Max: 50 |
|
||||
| `original_url` | url | ✅ | - |
|
||||
| `title` | text | ❌ | Max: 200 |
|
||||
| `description` | text | ❌ | Max: 500 |
|
||||
| `user_id` | relation | ❌ | Collection: users, Max select: 1, Cascade delete: ✅ |
|
||||
| `is_active` | bool | ❌ | - |
|
||||
| `password` | text | ❌ | - |
|
||||
| `max_clicks` | number | ❌ | Min: 0 |
|
||||
| `expires_at` | date | ❌ | - |
|
||||
| `click_count` | number | ❌ | - |
|
||||
| `tags` | json | ❌ | - |
|
||||
|
||||
**API Rules:**
|
||||
|
||||
- List/View rule: `` (leer = public)
|
||||
- Create rule: `@request.auth.id != ""`
|
||||
- Update rule: `@request.auth.id = user_id`
|
||||
|
|
@ -47,20 +48,21 @@ Da der Schema-Import nicht funktioniert (veraltetes Format), musst du die Collec
|
|||
|
||||
**Fields:**
|
||||
|
||||
| Field Name | Type | Required | Options |
|
||||
|------------|------|----------|---------|
|
||||
| `link_id` | relation | ✅ | Collection: links, Max select: 1, Cascade delete: ✅ |
|
||||
| `ip_hash` | text | ❌ | - |
|
||||
| `user_agent` | text | ❌ | - |
|
||||
| `referer` | text | ❌ | - |
|
||||
| `browser` | text | ❌ | - |
|
||||
| `device_type` | text | ❌ | - |
|
||||
| `os` | text | ❌ | - |
|
||||
| `country` | text | ❌ | - |
|
||||
| `city` | text | ❌ | - |
|
||||
| `clicked_at` | date | ❌ | - |
|
||||
| Field Name | Type | Required | Options |
|
||||
| ------------- | -------- | -------- | ---------------------------------------------------- |
|
||||
| `link_id` | relation | ✅ | Collection: links, Max select: 1, Cascade delete: ✅ |
|
||||
| `ip_hash` | text | ❌ | - |
|
||||
| `user_agent` | text | ❌ | - |
|
||||
| `referer` | text | ❌ | - |
|
||||
| `browser` | text | ❌ | - |
|
||||
| `device_type` | text | ❌ | - |
|
||||
| `os` | text | ❌ | - |
|
||||
| `country` | text | ❌ | - |
|
||||
| `city` | text | ❌ | - |
|
||||
| `clicked_at` | date | ❌ | - |
|
||||
|
||||
**API Rules:**
|
||||
|
||||
- List/View rule: `` (leer = public)
|
||||
- Create rule: `` (leer = public)
|
||||
- Update rule: `null` (keine Updates erlaubt)
|
||||
|
|
@ -74,20 +76,21 @@ Da der Schema-Import nicht funktioniert (veraltetes Format), musst du die Collec
|
|||
|
||||
**Fields:**
|
||||
|
||||
| Field Name | Type | Required | Options |
|
||||
|------------|------|----------|---------|
|
||||
| `name` | text | ✅ | - |
|
||||
| `owner` | relation | ✅ | Collection: users, Max select: 1 |
|
||||
| `members` | relation | ❌ | Collection: users, Multiple: ✅ |
|
||||
| `isActive` | bool | ❌ | - |
|
||||
| `planType` | select | ❌ | Values: free, team, enterprise |
|
||||
| `settings` | json | ❌ | - |
|
||||
| Field Name | Type | Required | Options |
|
||||
| ---------- | -------- | -------- | -------------------------------- |
|
||||
| `name` | text | ✅ | - |
|
||||
| `owner` | relation | ✅ | Collection: users, Max select: 1 |
|
||||
| `members` | relation | ❌ | Collection: users, Multiple: ✅ |
|
||||
| `isActive` | bool | ❌ | - |
|
||||
| `planType` | select | ❌ | Values: free, team, enterprise |
|
||||
| `settings` | json | ❌ | - |
|
||||
|
||||
## ✅ Nach dem Erstellen
|
||||
|
||||
1. **Speichern** nicht vergessen (Save button oben rechts)
|
||||
|
||||
2. **Test-Daten laden:**
|
||||
|
||||
```bash
|
||||
node scripts/seed-local-db.js
|
||||
```
|
||||
|
|
@ -100,6 +103,7 @@ Da der Schema-Import nicht funktioniert (veraltetes Format), musst du die Collec
|
|||
## 🎉 Fertig!
|
||||
|
||||
Deine lokale PocketBase ist jetzt bereit mit:
|
||||
|
||||
- Admin Account ✅
|
||||
- Collections ✅
|
||||
- Test-Daten (nach Seed-Script)
|
||||
|
|
@ -107,6 +111,7 @@ Deine lokale PocketBase ist jetzt bereit mit:
|
|||
## 📝 Test-URLs
|
||||
|
||||
Nach dem Seed-Script:
|
||||
|
||||
- http://localhost:5173/test1 - Normaler Link
|
||||
- http://localhost:5173/test2 - Link mit Click-Limit
|
||||
- http://localhost:5173/protected - Passwort: `secret123`
|
||||
|
|
@ -114,9 +119,11 @@ Nach dem Seed-Script:
|
|||
## 🔍 Troubleshooting
|
||||
|
||||
**"Collection not found" Fehler?**
|
||||
|
||||
- Stelle sicher, dass alle Collections erstellt und gespeichert wurden
|
||||
- Name muss exakt sein (case-sensitive)
|
||||
|
||||
**"Invalid relation" Fehler?**
|
||||
|
||||
- Erst Links Collection erstellen, dann Clicks
|
||||
- Users Collection existiert bereits (Standard Auth)
|
||||
- Users Collection existiert bereits (Standard Auth)
|
||||
|
|
|
|||
|
|
@ -3,13 +3,15 @@
|
|||
## ✅ Was wurde implementiert
|
||||
|
||||
### 1. Environment Separation
|
||||
|
||||
- **Development**: `http://localhost:8090` (lokal)
|
||||
- **Production**: `https://pb.ulo.ad` (Coolify)
|
||||
- Automatische Umgebungserkennung basierend auf `dev` Flag
|
||||
|
||||
### 2. Code-Änderungen
|
||||
|
||||
- ✅ `.env.development` - Lokale PocketBase URL
|
||||
- ✅ `.env.production` - Production PocketBase URL
|
||||
- ✅ `.env.production` - Production PocketBase URL
|
||||
- ✅ `src/lib/pocketbase.ts` - Dynamische URL-Auswahl
|
||||
- ✅ `src/routes/p/[username]/+page.server.ts` - Environment-basierte URL
|
||||
- ✅ `src/lib/scripts/update-links-collection.js` - Flexible URL
|
||||
|
|
@ -17,6 +19,7 @@
|
|||
- ✅ `src/hooks.server.ts` - CSP Headers für beide Umgebungen
|
||||
|
||||
### 3. Sicherheit
|
||||
|
||||
- Keine hardcoded Production URLs mehr
|
||||
- Vollständige Trennung von Dev/Prod Daten
|
||||
- Lokale Entwicklung ohne Internetverbindung möglich
|
||||
|
|
@ -36,19 +39,21 @@ cd backend
|
|||
|
||||
### 2. Admin Account erstellen
|
||||
|
||||
1. Öffne http://localhost:8090/_/
|
||||
1. Öffne http://localhost:8090/\_/
|
||||
2. Erstelle Admin Account (nur beim ersten Mal)
|
||||
3. Merke dir die Credentials
|
||||
|
||||
### 3. Schema importieren
|
||||
|
||||
**Option A: Manuell über UI**
|
||||
|
||||
1. Login als Admin
|
||||
2. Settings → Import/Export
|
||||
3. Load from JSON → `backend/pb_schema.json`
|
||||
4. Review → Confirm
|
||||
|
||||
**Option B: Automatisch (wenn Collections existieren)**
|
||||
|
||||
```bash
|
||||
# Schema ist bereits in backend/pb_migrations/
|
||||
cd backend
|
||||
|
|
@ -63,6 +68,7 @@ node scripts/seed-local-db.js
|
|||
```
|
||||
|
||||
Erstellt:
|
||||
|
||||
- 2 Test-User (test@localhost, demo@localhost)
|
||||
- 4 Test-Links (normal, protected, expired, limited)
|
||||
- Sample Click-Daten
|
||||
|
|
@ -80,21 +86,24 @@ npm run dev:all
|
|||
## 📝 Test-Credentials
|
||||
|
||||
### Users
|
||||
|
||||
```
|
||||
Email: test@localhost
|
||||
Password: test123456
|
||||
|
||||
Email: demo@localhost
|
||||
Email: demo@localhost
|
||||
Password: demo123456
|
||||
```
|
||||
|
||||
### Links
|
||||
|
||||
- `http://localhost:5173/test1` - Normaler Link
|
||||
- `http://localhost:5173/test2` - Mit Click-Limit (100)
|
||||
- `http://localhost:5173/protected` - Password: `secret123`
|
||||
- `http://localhost:5173/expired` - Abgelaufener Link
|
||||
|
||||
### Admin
|
||||
|
||||
```
|
||||
URL: http://localhost:8090/_/
|
||||
Email: [deine Admin Email]
|
||||
|
|
@ -104,6 +113,7 @@ Password: [dein Admin Password]
|
|||
## 🔍 Verification
|
||||
|
||||
### 1. Environment Check
|
||||
|
||||
```bash
|
||||
# In Browser Console sollte stehen:
|
||||
🔧 PocketBase URL: http://localhost:8090
|
||||
|
|
@ -112,12 +122,14 @@ Password: [dein Admin Password]
|
|||
```
|
||||
|
||||
### 2. API Health
|
||||
|
||||
```bash
|
||||
curl http://localhost:5173/health
|
||||
# sollte zeigen: "pocketbase": "running"
|
||||
```
|
||||
|
||||
### 3. Feature Tests
|
||||
|
||||
- [ ] User Registration
|
||||
- [ ] Login/Logout
|
||||
- [ ] Link erstellen
|
||||
|
|
@ -166,15 +178,15 @@ Falls Probleme: Admin UI → Settings → API Rules
|
|||
|
||||
## 📊 Development vs Production
|
||||
|
||||
| Aspekt | Development | Production |
|
||||
|--------|------------|------------|
|
||||
| Aspekt | Development | Production |
|
||||
| -------------- | --------------------- | ----------------- |
|
||||
| PocketBase URL | http://localhost:8090 | https://pb.ulo.ad |
|
||||
| Datenbank | Lokal (SQLite) | Cloud (Coolify) |
|
||||
| Auth | Test-Accounts | Echte User |
|
||||
| Stripe | Test-Keys | Live-Keys |
|
||||
| Redis | localhost:6379 | Coolify Redis |
|
||||
| SSL | Nein (HTTP) | Ja (HTTPS) |
|
||||
| CSP | Relaxed | Strict |
|
||||
| Datenbank | Lokal (SQLite) | Cloud (Coolify) |
|
||||
| Auth | Test-Accounts | Echte User |
|
||||
| Stripe | Test-Keys | Live-Keys |
|
||||
| Redis | localhost:6379 | Coolify Redis |
|
||||
| SSL | Nein (HTTP) | Ja (HTTPS) |
|
||||
| CSP | Relaxed | Strict |
|
||||
|
||||
## 🔄 Daten-Synchronisation
|
||||
|
||||
|
|
@ -212,6 +224,7 @@ cd backend && ./pocketbase serve
|
|||
## 🚢 Deployment
|
||||
|
||||
Beim Deployment nach Production:
|
||||
|
||||
1. Environment wird automatisch erkannt
|
||||
2. Production URLs werden verwendet
|
||||
3. Keine Code-Änderungen nötig!
|
||||
|
|
@ -230,4 +243,4 @@ npm run preview
|
|||
- [PocketBase Docs](https://pocketbase.io/docs/)
|
||||
- [Admin UI Guide](https://pocketbase.io/docs/admin-ui/)
|
||||
- [API Rules](https://pocketbase.io/docs/api-rules-and-filters/)
|
||||
- [Migrations](https://pocketbase.io/docs/migrations/)
|
||||
- [Migrations](https://pocketbase.io/docs/migrations/)
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ npm run dev:all
|
|||
```bash
|
||||
/app/pocketbase superuser create till.schneider@memoro.ai p0ck3t-RA1N
|
||||
```
|
||||
|
||||
|
||||
### Über Web-Interface
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue