Quick Start
Build a complete CRUD API in 5 minutes.
Blog API Example
Create a full blog API with users and posts.
1. Define Routes
Add to config.json:
json
{
"supabase": {
"url": "{{env.SUPABASE_URL}}",
"anonKey": "{{env.SUPABASE_ANON_KEY}}"
},
"jwt": {
"secret": "{{env.JWT_SECRET}}"
},
"routes": [
{
"path": "/posts",
"method": "get",
"description": "List all posts",
"tags": ["Posts"],
"supabaseQueries": [{
"table": "posts",
"operation": "select",
"select": "*, users(id, name)",
"order": { "column": "created_at", "ascending": false }
}]
},
{
"path": "/posts/:id",
"method": "get",
"description": "Get post by ID",
"tags": ["Posts"],
"supabaseQueries": [{
"table": "posts",
"operation": "select",
"select": "*",
"filters": [{
"column": "id",
"operator": "eq",
"value": "{{params.id}}"
}],
"single": true
}]
},
{
"path": "/posts",
"method": "post",
"description": "Create post",
"tags": ["Posts"],
"requireAuth": true,
"supabaseQueries": [{
"table": "posts",
"operation": "insert",
"data": {
"title": "{{body.title}}",
"content": "{{body.content}}",
"user_id": "{{auth.sub}}"
},
"select": "*",
"single": true
}]
},
{
"path": "/posts/:id",
"method": "put",
"description": "Update post",
"tags": ["Posts"],
"requireAuth": true,
"supabaseQueries": [{
"table": "posts",
"operation": "update",
"data": {
"title": "{{body.title}}",
"content": "{{body.content}}"
},
"filters": [{
"column": "id",
"operator": "eq",
"value": "{{params.id}}"
}],
"select": "*",
"single": true
}]
},
{
"path": "/posts/:id",
"method": "delete",
"description": "Delete post",
"tags": ["Posts"],
"requireAuth": true,
"supabaseQueries": [{
"table": "posts",
"operation": "delete",
"filters": [{
"column": "id",
"operator": "eq",
"value": "{{params.id}}"
}]
}]
}
]
}2. Create Database Tables
Apply the migration:
bash
npm run auto-migrateOr manually in Supabase SQL Editor:
sql
create table users (
id uuid primary key default gen_random_uuid(),
name text not null,
email text unique not null,
created_at timestamp default now()
);
create table posts (
id uuid primary key default gen_random_uuid(),
title text not null,
content text,
user_id uuid references users(id),
created_at timestamp default now()
);3. Start Server
bash
npm run dev4. Test Your API
bash
# Get all posts
curl http://localhost:3000/posts
# Create post (authenticated)
curl -X POST http://localhost:3000/posts \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"title": "Hello", "content": "World"}'
# Get single post
curl http://localhost:3000/posts/123
# Update post
curl -X PUT http://localhost:3000/posts/123 \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"title": "Updated"}'
# Delete post
curl -X DELETE http://localhost:3000/posts/123 \
-H "Authorization: Bearer <token>"Generate JWT Token
bash
npm run generate-jwtWhat You Get
- Full CRUD API
- JWT authentication on write operations
- Automatic validation
- OpenAPI documentation at
/ui - Relational data (posts with user info)
- Sorting and filtering
Next Steps
- Routes - Route configuration options
- Authentication - JWT and Firebase Auth
- Database - Advanced queries