| .. | ||
| docs | ||
| migrations | ||
| scripts | ||
| src | ||
| test | ||
| .dockerignore | ||
| .env.example | ||
| .env.prod | ||
| .eslintrc.js | ||
| .gitignore | ||
| .npmrc | ||
| .prettierrc | ||
| Dockerfile | ||
| get-db-schema.sql | ||
| make-character-public.sql | ||
| nest-cli.json | ||
| NESTJS_CLS_SOLUTION.md | ||
| package.json | ||
| README.md | ||
| README_CHARACTER_UPDATE_FIX.md | ||
| RLS_IMPLEMENTATION_GUIDE.md | ||
| RUN_THIS_MIGRATION.sql | ||
| schema-diagram.dbml | ||
| schema-diagram.html | ||
| test-public-characters.sql | ||
| test-supabase-mcp.ts | ||
| test-trigger.sql | ||
| tsconfig.build.json | ||
| tsconfig.json | ||
storyteller-backend
Authentication
This application uses Supabase for authentication, following a multi-Supabase architecture:
- A central auth Supabase instance ("mana") handles user authentication
- An application-specific Supabase instance ("maerchenzauber") handles application data
- The NestJS backend serves as a token exchange middleware and application server
Setup Requirements
You need to set up two Supabase instances:
- mana - Central authentication service
- maerchenzauber - Application-specific database
See auth.md for detailed setup instructions and database schema.
Environment Variables
Configure the following environment variables (see .env.example):
MANA_SUPABASE_URL- URL of the central auth Supabase instanceMANA_SUPABASE_ANON_KEY- Anon key for the central auth SupabaseMANA_JWT_SECRET- JWT secret for verifying tokens from the central authMAERCHENZAUBER_SUPABASE_URL- URL of the application Supabase instanceMAERCHENZAUBER_SUPABASE_ANON_KEY- Anon key for the application SupabaseMAERCHENZAUBER_JWT_SECRET- JWT secret for signing tokens for the application SupabaseAPP_ID- Application identifier (default: "8d2f5ddb-e251-4b3b-8802-84022a7ac77f")
Build and Deploy
gcloud config set project storyteller-a1fde
build it and deploy it to cloud run
gcloud builds submit --tag gcr.io/storyteller-a1fde/storyteller-api:v1.5.7
after sucesfull build it shows something like this
gcr.io/storyteller-a1fde/storyteller-api:v1.5.7
then run
gcloud run deploy storyteller-api
--image gcr.io/storyteller-a1fde/storyteller-api:v1.5.7
--region=us-central1
--platform=managed
--allow-unauthenticated
currently deployed: gcr.io/storyteller-a1fde/storyteller-api:v1.5.7
Testing Request
curl -X POST http://localhost:3000/story
-H "Content-Type: application/json"
-d '{
"characters": ["7d800d18-dcb4-4a48-addf-c6a6a88dd7ed"],
"storyDescription": "A fun adventure story about friendship and courage",
"illustratorId": "QsqH9Cyds24rRbAYf6zT",
"authorId": "fKMNQsgKojozOHTnjAbs"
}'