### Refine Quickstart: Integrate Supabase Source: https://supabase.com/llms/guides.txt Guides you on integrating Supabase with Refine applications for data management and querying. Familiarity with Refine is beneficial. ```javascript import { SupabaseRestDataProvider } from '@refinedev/supabase'; const dataProvider = SupabaseRestDataProvider({ instanceUrl: 'YOUR_SUPABASE_URL', apiKey: 'YOUR_SUPABASE_KEY', }); // Example usage in Refine App: // // {/* ... your resources ... */} // ``` -------------------------------- ### Flutter Quickstart: Integrate Supabase Source: https://supabase.com/llms/guides.txt Guide to setting up a Supabase project, adding sample data, and querying from a Flutter application. Requires Dart and Flutter knowledge. ```dart import 'package:supabase_flutter/supabase_flutter.dart'; Future fetchTodos() async { final supabase = Supabase.instance.client; final response = await supabase.from('todos').select('*').execute(); if (response.error != null) { print('Error fetching todos: ${response.error!.message}'); return; } print('Todos: ${response.data}'); } void main() async { await Supabase.initialize(url: 'YOUR_SUPABASE_URL', anonKey: 'YOUR_SUPABASE_KEY'); await fetchTodos(); } ``` -------------------------------- ### React Quickstart: Integrate Supabase Source: https://supabase.com/llms/guides.txt Learn to build a Supabase project, populate it with sample data, and query from a React application. This guide assumes basic knowledge of React. ```javascript const { createClient } = require('@supabase/supabase-js'); const supabaseUrl = 'YOUR_SUPABASE_URL'; const supabaseKey = 'YOUR_SUPABASE_KEY'; const supabase = createClient(supabaseUrl, supabaseKey); async function getTodos() { const { data, error } = await supabase .from('todos') .select('*'); if (error) { console.error('Error fetching todos:', error); return; } console.log('Todos:', data); } getTodos(); ``` -------------------------------- ### Hono Quickstart: Integrate Supabase Source: https://supabase.com/llms/guides.txt Learn to set up a Supabase project, add data, secure it with authentication, and query from a Hono application. This guide is for Hono users. ```javascript import { Hono } from 'hono'; import { createClient } from '@supabase/supabase-js'; const app = new Hono(); const supabaseUrl = 'YOUR_SUPABASE_URL'; const supabaseKey = 'YOUR_SUPABASE_KEY'; const supabase = createClient(supabaseUrl, supabaseKey); app.get('/todos', async (c) => { const { data, error } = await supabase.from('todos').select('*'); if (error) { return c.json({ error: error.message }, 500); } return c.json(data); }); export default app; ``` -------------------------------- ### Project Start Command Source: https://supabase.com/llms/guides.txt This bash command initiates the development server for the project, typically serving the application on localhost:3000. Ensure Node.js and npm are installed. ```bash npm start ``` -------------------------------- ### Nuxt Quickstart: Integrate Supabase Source: https://supabase.com/llms/guides.txt Guides you through creating a Supabase project, adding sample data, and querying it from a Nuxt application. Requires basic understanding of Nuxt. ```javascript import { createClient } from '@supabase/supabase-js'; const supabaseUrl = process.env.NUXT_PUBLIC_SUPABASE_URL; const supabaseKey = process.env.NUXT_PUBLIC_SUPABASE_ANON_KEY; const supabase = createClient(supabaseUrl, supabaseKey); export default { async asyncData({ $supabase }) { const { data, error } = await $supabase.from('todos').select('*'); if (error) console.error(error); return { todos: data }; }, // ... other Nuxt component options } ``` -------------------------------- ### SolidJS Quickstart: Integrate Supabase Source: https://supabase.com/llms/guides.txt A guide to integrating Supabase with SolidJS applications, covering project creation, data seeding, and querying. Requires SolidJS knowledge. ```javascript import { createSignal, onMount } from 'solid-js'; import { createClient } from '@supabase/supabase-js'; const supabaseUrl = 'YOUR_SUPABASE_URL'; const supabaseKey = 'YOUR_SUPABASE_KEY'; const supabase = createClient(supabaseUrl, supabaseKey); function App() { const [todos, setTodos] = createSignal([]); onMount(async () => { const { data, error } = await supabase.from('todos').select('*'); if (error) { console.error('Error fetching todos:', error); return; } setTodos(data); }); return (

Todos

); } export default App; ``` -------------------------------- ### SvelteKit Quickstart: Integrate Supabase Source: https://supabase.com/llms/guides.txt Learn how to integrate Supabase into a SvelteKit application, including database setup and data querying. Assumes familiarity with SvelteKit. ```javascript import { createClient } from '@supabase/supabase-js'; const supabaseUrl = 'YOUR_SUPABASE_URL'; const supabaseKey = 'YOUR_SUPABASE_KEY'; const supabase = createClient(supabaseUrl, supabaseKey); export async function load() { const { data, error } = await supabase.from('todos').select('*'); if (error) { console.error('Error fetching todos:', error); return { todos: [], }; } return { todos: data, }; } // In your +page.svelte: // // // ``` -------------------------------- ### Hello World Routing in Deno Source: https://supabase.com/llms/guides.txt A basic Deno server example demonstrating GET and POST request handling. It responds with 'Hello World!' for GET requests and a personalized greeting based on JSON input for POST requests. This code runs directly within Deno without external dependencies. ```typescript Deno.serve(async (req) => { if (req.method === 'GET') { return new Response('Hello World!') } const { name } = await req.json() if (name) { return new Response(`Hello ${name}!`) } return new Response('Hello World!') }) ``` -------------------------------- ### Create and Insert Data for Full Text Search Example Source: https://supabase.com/llms/guides.txt Provides the SQL statements to create a 'books' table and populate it with example data for demonstrating Full Text Search functionality. This setup is essential for the subsequent usage examples. ```sql create table books ( id serial primary key, title text, author text, description text ); insert into books (title, author, description) values ( 'The Poky Little Puppy', 'Janette Sebring Lowrey', 'Puppy is slower than other, bigger animals.' ), ('The Tale of Peter Rabbit', 'Beatrix Potter', 'Rabbit eats some vegetables.'), ('Tootle', 'Gertrude Crampton', 'Little toy train has big dreams.'), ( 'Green Eggs and Ham', 'Dr. Seuss', 'Sam has changing food preferences and eats unusually colored food.' ), ( 'Harry Potter and the Goblet of Fire', 'J.K. Rowling', 'Fourth year of school starts, big drama ensues.' ); ``` -------------------------------- ### Install and Start Roboflow Inference Server Source: https://supabase.com/llms/guides.txt Installs the necessary Roboflow Inference packages and starts the local inference server. This server provides an API endpoint for running computer vision models locally. Ensure Docker is installed before running this command. ```bash pip install inference inference-cli inference-sdk && inference server start ``` -------------------------------- ### Install Postgres and Verify psql (Windows) Source: https://supabase.com/llms/guides.txt This snippet covers downloading and installing PostgreSQL on Windows, adding its binary directory to the system PATH, and verifying the psql command-line tool installation. ```shell C:\Program Files\PostgreSQL\17\bin ``` ```shell psql --version ``` -------------------------------- ### supabase start Source: https://supabase.com/llms/cli.txt Start containers for Supabase local development. ```APIDOC ## POST /llmstxt/supabase_llms_txt/start ### Description Starts the Supabase local development stack. Requires `supabase/config.toml` to be initialized first. ### Method POST ### Endpoint /llmstxt/supabase_llms_txt/start ### Parameters #### Path Parameters None #### Query Parameters - **exclude** (string) - Optional - Comma-separated list of services to exclude (e.g., `gotrue,imgproxy`). Can be specified multiple times. - **ignore-health-check** (boolean) - Optional - Ignore health check errors for started containers. #### Request Body None ### Request Example ```bash supabase start supabase start -x gotrue,imgproxy supabase start --ignore-health-check ``` ### Response #### Success Response (200) - **message** (string) - Indicates that the Supabase local development stack has started. #### Response Example ```json { "message": "Supabase local development stack started successfully." } ``` ``` -------------------------------- ### Hello World Routing in Express.js Source: https://supabase.com/llms/guides.txt An Express.js example for setting up GET and POST routes. It requires the 'express' npm package and uses 'express.json()' middleware to parse JSON request bodies. The server listens on port 3000. ```javascript import express from 'npm:express@4.18.2' const app = express() app.use(express.json()) // If you want a payload larger than 100kb, then you can tweak it here: // app.use( express.json({ limit : "300kb" })); const port = 3000 app.get('/hello-world', (req, res) => { res.send('Hello World!') }) app.post('/hello-world', (req, res) => { const { name } = req.body res.send(`Hello ${name}!`) }) app.listen(port, () => { console.log(`Example app listening on port ${port}`) }) ``` -------------------------------- ### Initialize SvelteKit App and Install Supabase Client Source: https://supabase.com/llms/guides.txt This snippet demonstrates the commands to create a new SvelteKit project, install dependencies, and add the Supabase JavaScript client library. It assumes you have Node.js and npm installed. ```bash npx sv create supabase-sveltekit cd supabase-sveltekit npm install npm install @supabase/supabase-js ``` -------------------------------- ### Hello World Routing in Hono Source: https://supabase.com/llms/guides.txt A Hono example demonstrating GET and POST routes. It uses 'jsr:@hono/hono' and integrates with Deno.serve for handling requests. This snippet efficiently manages JSON parsing and response generation. ```typescript import { Hono } from 'jsr:@hono/hono' const app = new Hono() app.post('/hello-world', async (c) => { const { name } = await c.req.json() return new Response(`Hello ${name}!`) }) app.get('/hello-world', (c) => { return new Response('Hello World!') }) Deno.serve(app.fetch) ``` -------------------------------- ### Using Index Advisor for Query Optimization Source: https://supabase.com/llms/guides.txt This SQL example demonstrates how to use the 'index_advisor' extension to get recommendations for indexes that can improve the performance of a given SQL query. It takes a query string as input and returns potential index statements, along with cost savings and errors. This is useful for automated performance tuning. ```sql select * from index_advisor('select book.id from book where title = $1'); ``` -------------------------------- ### Supabase multi-environment configuration example Source: https://supabase.com/llms/guides.txt This TOML file defines a multi-environment setup for a Supabase project, including default API and DB settings, and specific configurations for 'staging' and 'production' remotes. It demonstrates overrides for API limits and database pool sizes. ```toml # Default configuration for all branches [api] enabled = true port = 54321 schemas = ["public", "storage", "graphql_public"] [db] port = 54322 pool_size = 10 # Staging-specific configuration [remotes.staging] project_id = "staging-project-ref" [remotes.staging.api] max_rows = 1000 [remotes.staging.db.seed] sql_paths = ["./seeds/staging.sql"] # Production-specific configuration [remotes.production] project_id = "prod-project-ref" [remotes.production.api] max_rows = 500 [remotes.production.db] pool_size = 25 ``` -------------------------------- ### Install Postgres.js with npm Source: https://supabase.com/llms/guides.txt Installs the Postgres.js library and its necessary dependencies using npm. This is the first step to set up your database connection in a Node.js environment. ```shell npm i postgres ``` -------------------------------- ### Install Postgres and Verify psql (macOS) Source: https://supabase.com/llms/guides.txt This snippet explains how to install PostgreSQL on macOS using Homebrew, and how to verify the psql installation, including steps to add it to the PATH if necessary. ```shell brew install postgresql@17 ``` ```shell psql --version ``` ```shell brew info postgresql@17 ``` ```shell echo 'export PATH="/opt/homebrew/opt/postgresql@17/bin:$PATH"' >> ~/.zshrc ``` -------------------------------- ### Android Kotlin Quickstart: Integrate Supabase Source: https://supabase.com/llms/guides.txt Integrate Supabase into an Android Kotlin application, covering project setup, database population, and data retrieval. Requires Kotlin and Android development knowledge. ```kotlin import io.github.jan.supabase.createSupabaseClient import io.github.jan.supabase.gotrue.Auth import io.github.jan.supabase.postgrest.Postgrest object SupabaseManager { val client = createSupabaseClient( "YOUR_SUPABASE_URL", "YOUR_SUPABASE_KEY" ) { install(Auth) install(Postgrest) } } // Example usage in an Activity or Fragment: // CoroutineScope(Dispatchers.IO).launch { // val todos: List = SupabaseManager.client.from("todos").select('*').decodeAs>() ?: emptyList() // withContext(Dispatchers.Main) { // // Update UI with todos // } // } // data class Todo(val id: Int, val title: String) ``` -------------------------------- ### Initialize Ionic React App and Install Supabase JS Source: https://supabase.com/llms/guides.txt Installs the Ionic CLI, creates a new Ionic React app, navigates into the project directory, and installs the Supabase JavaScript client library. ```bash npm install -g @ionic/cli ionic start supabase-ionic-react blank --type react cd supabase-ionic-react npm install @supabase/supabase-js ``` -------------------------------- ### GET /llmstxt/supabase_llms_txt/http_get Source: https://supabase.com/llms/guides.txt Creates an HTTP GET request, returning the request's ID. HTTP requests are not started until the transaction is committed. ```APIDOC ## GET /llmstxt/supabase_llms_txt/http_get ### Description Creates an HTTP GET request, returning the request's ID. HTTP requests are not started until the transaction is committed. ### Method GET ### Endpoint /llmstxt/supabase_llms_txt/http_get ### Parameters #### Path Parameters None #### Query Parameters - **url** (text) - Required - The URL for the request. - **params** (jsonb) - Optional - Key/value pairs to be URL encoded and appended to the `url`. Defaults to `{}`. - **headers** (jsonb) - Optional - Key/values to be included in request headers. Defaults to `{}`. - **timeout_milliseconds** (int) - Optional - The maximum number of milliseconds the request may take before being canceled. Defaults to 2000. ### Request Example ```sql SELECT net.http_get('https://news.ycombinator.com') AS request_id; ``` ### Response #### Success Response (200) - **request_id** (bigint) - The reference ID for the request. #### Response Example ```json { "request_id": 1 } ``` ``` -------------------------------- ### Route Parameters - Express.js Example Source: https://supabase.com/llms/guides.txt This Express.js example demonstrates handling route parameters for task-related operations. It sets up routes for getting all tasks, creating a task, getting a specific task by ID, updating a task, and deleting a task using route parameters like ':id'. ```typescript import express from 'npm:express@4.18.2' const app = express() app.use(express.json()) app.get('/tasks', async (req, res) => { // return all tasks }) app.post('/tasks', async (req, res) => { // create a task }) app.get('/tasks/:id', async (req, res) => { const id = req.params.id const task = {} // get task res.json(task) }) app.patch('/tasks/:id', async (req, res) => { const id = req.params.id // modify task }) app.delete('/tasks/:id', async (req, res) => { const id = req.params.id // delete task }) ``` -------------------------------- ### Bootstrap Hono App with Supabase CLI Source: https://supabase.com/llms/guides.txt This command bootstraps a new Hono example application integrated with Supabase using the Supabase CLI. Ensure you have the Supabase CLI installed globally. This sets up the basic project structure and necessary configurations for a Hono project intended for Supabase usage. ```bash npx supabase@latest bootstrap hono ``` -------------------------------- ### Postgres HTTP GET Request Usage Example Source: https://supabase.com/llms/guides.txt Demonstrates how to use the net.http_get function to make a GET request to a specified URL and retrieve the request ID. ```sql select net.http_get('https://news.ycombinator.com') as request_id; request_id ---------- 1 (1 row) ``` -------------------------------- ### Next.js Quickstart: Integrate Supabase Source: https://supabase.com/llms/guides.txt Discover how to set up a Supabase project, add sample data, and perform queries within a Next.js application. Familiarity with Next.js is recommended. ```javascript import { createClient } from '@supabase/supabase-js'; const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL; const supabaseKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY; const supabase = createClient(supabaseUrl, supabaseKey); export async function getStaticProps() { const { data, error } = await supabase .from('todos') .select('*'); if (error) { throw new Error('Failed to fetch todos'); } return { props: { todos: data, }, }; } function TodosPage({ todos }) { return (
    {todos.map(todo => (
  • {todo.title}
  • ))}
); } ``` -------------------------------- ### Start RedwoodJS Development Server Source: https://supabase.com/llms/guides.txt Starts the RedwoodJS development server. This command is essential for viewing project changes live during development. Ensure you have the RedwoodJS CLI installed. ```bash yarn rw dev ``` -------------------------------- ### Retrieve Supabase Auth Rate Limits Source: https://supabase.com/llms/guides.txt Fetches the current rate limits configured for Supabase Auth endpoints. Rate limits are in place to protect services from abuse and can be customized in the Supabase dashboard or managed via the Management API. This example uses `curl` to make a GET request to the Supabase API and `jq` to parse the JSON response, filtering for keys starting with 'rate_limit_'. ```bash # Get your access token from https://supabase.com/dashboard/account/tokens export SUPABASE_ACCESS_TOKEN="your-access-token" export PROJECT_REF="your-project-ref" # Get current rate limits curl -X GET "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \ -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \ | jq 'to_entries | map(select(.key | startswith("rate_limit_"))) | from_entries' ``` -------------------------------- ### Handle Supabase Auth Callback in Express Source: https://supabase.com/llms/guides.txt This snippet provides an example of handling the Supabase authentication callback within an Express.js application. It sets up a GET route to process the authorization code, exchange it for a session using '@supabase/ssr', and manage cookies. It relies on environment variables for Supabase credentials and assumes a basic Express app setup. Note: The provided Express snippet is incomplete. ```javascript ... app.get("/auth/callback", async function (req, res) { const code = req.query.code const next = req.query.next ?? "/" if (code) { const supabase = createServerClient( process.env.SUPABASE_URL, process.env.SUPABASE_PUBLISHABLE_KEY, { cookies: { getAll() { return parseCookieHeader(context.req.headers.cookie ?? '') }, ``` -------------------------------- ### Install and Setup supabase-dbdev Extension Source: https://supabase.com/llms/guides.txt This SQL script installs the 'supabase-dbdev' extension, a package manager for Postgres, which is a prerequisite for using database development tools and community packages. It ensures necessary extensions like 'http' and 'pg_tle' are present, then fetches and installs the latest version of 'supabase-dbdev'. ```sql create extension if not exists http with schema extensions; create extension if not exists pg_tle; drop extension if exists "supabase-dbdev"; select pgtle.uninstall_extension_if_exists('supabase-dbdev'); select pgtle.install_extension( 'supabase-dbdev', resp.contents ->> 'version', 'PostgreSQL package manager', resp.contents ->> 'sql' ) from extensions.http( ( 'GET', 'https://api.database.dev/rest/v1/' || 'package_versions?select=sql,version' || '&package_name=eq.supabase-dbdev' || '&order=version.desc' || '&limit=1', array[ ('apiKey', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhtdXB0cHBsZnZpaWZyYndtbXR2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODAxMDczNzIsImV4cCI6MTk5NTY4MzM3Mn0.z2CN0mvO2No8wSi46Gw59DFGCTJrzM0AQKsu_5k134s')::extensions.http_header ], null, null ) ) x, lateral ( select ((row_to_json(x) -> 'content') #>> '{}')::json -> 0 ) resp(contents); create extension "supabase-dbdev"; select dbdev.install('supabase-dbdev'); -- Drop and recreate the extension to ensure a clean installation drop extension if exists "supabase-dbdev"; create extension "supabase-dbdev"; ``` -------------------------------- ### Discord Authentication Setup Source: https://supabase.com/llms/guides.txt Guides users through setting up Discord as an OAuth provider for their Supabase project. ```APIDOC ## Discord Authentication Setup ### Description This section details the steps required to enable Discord login for your application using Supabase. It involves configuring a Discord Application and integrating its credentials into your Supabase project. ### Overview 1. **Discord Application Setup**: Create and configure an application in the [Discord Developer Portal](https://discord.com/developers). 2. **Supabase Configuration**: Add your Discord OAuth Client ID and Client Secret to your Supabase Project settings. 3. **Client-Side Integration**: Implement the login flow in your Supabase JS Client application. ### Steps 1. **Access Discord Developer Portal**: Log in to [discord.com](https://discord.com/) and navigate to the [Discord Developer Portal](https://discord.com/developers). 2. **Create Discord Application**: Click 'New Application', provide a name, and create it. 3. **Configure OAuth2**: In the application settings, go to 'OAuth2' > 'General'. Add your Supabase project's callback URL (e.g., `https://.supabase.co/auth/v1/callback`) to the 'Redirects' list and save changes. 4. **Obtain Credentials**: Copy the 'Client ID' and 'Client Secret' from the 'Client Information' section. 5. **Configure Supabase**: * Go to your Supabase Project Dashboard. * Navigate to 'Authentication' > 'Providers'. * Expand the 'Discord' section. * Enable Discord and paste your 'Client ID' and 'Client Secret' into the respective fields. * Click 'Save'. ### Note For local development testing with OAuth, refer to the [Supabase CLI local development docs](/docs/guides/cli/local-development#use-auth-locally). ``` -------------------------------- ### Install Ionic CLI and Start New Angular App Source: https://supabase.com/llms/guides.txt Installs the Ionic CLI globally and then creates a new blank Ionic Angular project named 'supabase-ionic-angular'. It also navigates into the newly created project directory. ```bash npm install -g @ionic/cli ionic start supabase-ionic-angular blank --type angular cd supabase-ionic-angular ``` -------------------------------- ### Install Dependencies for SecureStore Integration Source: https://supabase.com/llms/guides.txt Installs additional dependencies required for encrypting session information using Expo SecureStore, AES-256 encryption, and random value generation. This setup enhances the security of stored user session data. ```bash npm install @supabase/supabase-js npm install @rneui/themed @react-native-async-storage/async-storage npm install aes-js react-native-get-random-values npm install --save-dev @types/aes-js npx expo install expo-secure-store ``` -------------------------------- ### Set up Ubuntu VM for Migration Source: https://supabase.com/llms/guides.txt Installs PostgreSQL client and tools on an Ubuntu VM, preparing it for database migration tasks. It also sets up a tmux session for managing the migration process. ```bash # Install Postgres client and tools sudo apt update sudo apt install software-properties-common sudo sh -c 'echo "deb http://apt.Postgres.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' wget --quiet -O - https://www.Postgres.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt update sudo apt install Postgres-client-17 tmux htop iotop moreutils # Start or attach to tmux session tmux a -t migration || tmux new -s migration ``` -------------------------------- ### Install Supabase Test Helpers Package Source: https://supabase.com/llms/guides.txt This SQL command installs the 'basejump-supabase_test_helpers' package using the database.dev tool. This package provides utilities that simplify testing Supabase-specific features, such as user management and RLS policy testing, reducing the need for manual setup and boilerplate code. ```sql select dbdev.install('basejump-supabase_test_helpers'); create extension if not exists "basejump-supabase_test_helpers" version '0.0.6'; ``` -------------------------------- ### supabase init Source: https://supabase.com/llms/cli.txt Initialize configurations for Supabase local development. ```APIDOC ## POST /llmstxt/supabase_llms_txt/init ### Description Initialize configurations for Supabase local development. A `supabase/config.toml` file is created in your current working directory. ### Method POST ### Endpoint /llmstxt/supabase_llms_txt/init ### Parameters #### Path Parameters None #### Query Parameters - **workdir** (string) - Optional - Override the directory path for configuration files. #### Request Body None ### Request Example ```bash supabase init --workdir /path/to/your/project ``` ### Response #### Success Response (200) - **message** (string) - Indicates successful initialization and creation of `supabase/config.toml`. #### Response Example ```json { "message": "Supabase local development initialized. supabase/config.toml created." } ``` ``` -------------------------------- ### PostgreSQL EXPLAIN execution plan example Source: https://supabase.com/llms/guides.txt Illustrates the typical output format of a PostgreSQL `EXPLAIN` query plan when executed via the Supabase client. This text-based representation details the query execution steps, costs, and estimated row counts, helping developers understand query optimization. ```text Aggregate (cost=33.34..33.36 rows=1 width=112) -> Limit (cost=0.00..18.33 rows=1000 width=40) -> Seq Scan on instruments (cost=0.00..22.00 rows=1200 width=40) ``` -------------------------------- ### Route Parameters - Oak Example Source: https://supabase.com/llms/guides.txt This Oak (Deno) example illustrates the use of route parameters for managing tasks. It defines a router that handles GET, POST, and PATCH requests for '/tasks' and '/tasks/:id', allowing for retrieval, creation, and modification of tasks based on their IDs extracted from the URL. ```typescript import { Application } from 'jsr:@oak/oak/application' import { Router } from 'jsr:@oak/oak/router' const router = new Router() let tasks: { [id: string]: any } = {} router .get('/tasks', (ctx) => { ctx.response.body = Object.values(tasks) }) .post('/tasks', async (ctx) => { const body = ctx.request.body() const { name } = await body.value const id = Math.random().toString(36).substring(7) tasks[id] = { id, name } ctx.response.body = tasks[id] }) .get('/tasks/:id', (ctx) => { const id = ctx.params.id const task = tasks[id] if (task) { ctx.response.body = task } else { ctx.response.status = 404 ctx.response.body = 'Task not found' } }) .patch('/tasks/:id', async (ctx) => { const id = ctx.params.id const body = ctx.request.body() const updates = await body.value const task = tasks[id] if (task) { tasks[id] = { ...task, ...updates } ctx.response.body = tasks[id] } else { ctx.response.status = 404 ctx.response.body = 'Task not found' } }) ``` -------------------------------- ### Setup Test Environment - SQL Source: https://supabase.com/llms/guides.txt This SQL code sets up the test environment by creating test users, profiles, and organizations. It also inserts sample data, including posts, to test different access levels and RLS policies. The setup includes authenticating as the service role to bypass RLS for initial setup. ```sql -- Assuming we already have: 000-setup-tests-hooks.sql file we can use tests helpers begin; -- Declare total number of tests select plan(10); -- Create test users select tests.create_supabase_user('org_owner', 'owner@test.com'); select tests.create_supabase_user('org_admin', 'admin@test.com'); select tests.create_supabase_user('org_editor', 'editor@test.com'); select tests.create_supabase_user('premium_user', 'premium@test.com'); select tests.create_supabase_user('free_user', 'free@test.com'); select tests.create_supabase_user('scheduler', 'scheduler@test.com'); select tests.create_supabase_user('free_author', 'free_author@test.com'); -- Create profiles for test users insert into profiles (id, username, full_name) values (tests.get_supabase_uid('org_owner'), 'org_owner', 'Organization Owner'), (tests.get_supabase_uid('org_admin'), 'org_admin', 'Organization Admin'), (tests.get_supabase_uid('org_editor'), 'org_editor', 'Organization Editor'), (tests.get_supabase_uid('premium_user'), 'premium_user', 'Premium User'), (tests.get_supabase_uid('free_user'), 'free_user', 'Free User'), (tests.get_supabase_uid('scheduler'), 'scheduler', 'Scheduler User'), (tests.get_supabase_uid('free_author'), 'free_author', 'Free Author'); -- First authenticate as service role to bypass RLS for initial setup select tests.authenticate_as_service_role(); -- Create test organizations and setup data with new_org as ( insert into organizations (name, slug, plan_type, max_posts) values ('Test Org', 'test-org', 'pro', 100), ('Premium Org', 'premium-org', 'enterprise', 1000), ('Schedule Org', 'schedule-org', 'pro', 100), ('Free Org', 'free-org', 'free', 2) returning id, slug ), -- Setup members and posts member_setup as ( insert into org_members (org_id, user_id, role) select org.id, user_id, role from new_org org cross join ( values (tests.get_supabase_uid('org_owner'), 'owner'), (tests.get_supabase_uid('org_admin'), 'admin'), (tests.get_supabase_uid('org_editor'), 'editor'), (tests.get_supabase_uid('premium_user'), 'viewer'), (tests.get_supabase_uid('scheduler'), 'editor'), (tests.get_supabase_uid('free_author'), 'editor') ) as members(user_id, role) where org.slug = 'test-org' or (org.slug = 'premium-org' and role = 'viewer') or (org.slug = 'schedule-org' and role = 'editor') or (org.slug = 'free-org' and role = 'editor') ) -- Setup initial posts insert into posts (title, content, org_id, author_id, status, is_premium, scheduled_for) select title, content, org.id, author_id, status, is_premium, scheduled_for from new_org org cross join ( values ('Premium Post', 'Premium content', tests.get_supabase_uid('premium_user'), 'published', true, null), ('Free Post', 'Free content', tests.get_supabase_uid('premium_user'), 'published', false, null), ('Future Post', 'Future content', tests.get_supabase_uid('scheduler'), 'published', false, '2024-01-02 12:00:00+00'::timestamptz) ) as posts(title, content, author_id, status, is_premium, scheduled_for) where org.slug in ('premium-org', 'schedule-org'); ``` -------------------------------- ### Create SvelteKit App (Terminal) Source: https://supabase.com/llms/guides.txt This command initializes a new SvelteKit project named 'my-app' using the 'npm create' command. It serves as the starting point for building a SvelteKit application. ```bash npx sv create my-app ``` -------------------------------- ### Initialize Test Environment and Utilities with SQL Source: https://supabase.com/llms/guides.txt This SQL script installs necessary extensions like pgtap, http, and pg_tle. It also includes logic to install the 'supabase-dbdev' package from a remote API and the 'basejump-supabase_test_helpers' extension. Finally, it runs a simple 'always green' test to confirm the setup. ```sql -- install tests utilities -- install pgtap extension for testing create extension if not exists pgtap with schema extensions; /* --------------------- ---- install dbdev ---- ---------------------- Requires: - pg_tle: https://github.com/aws/pg_tle - pgsql-http: https://github.com/pramsey/pgsql-http */ create extension if not exists http with schema extensions; create extension if not exists pg_tle; drop extension if exists "supabase-dbdev"; select pgtle.uninstall_extension_if_exists('supabase-dbdev'); select pgtle.install_extension( 'supabase-dbdev', resp.contents ->> 'version', 'PostgreSQL package manager', resp.contents ->> 'sql' ) from extensions.http( ( 'GET', 'https://api.database.dev/rest/v1/' || 'package_versions?select=sql,version' || '&package_name=eq.supabase-dbdev' || '&order=version.desc' || '&limit=1', array[ ('apiKey', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhtdXB0cHBsZnZpaWZyYndtbXR2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODAxMDczNzIsImV4cCI6MTk5NTY4MzM3Mn0.z2CN0mvO2No8wSi46Gw59DFGCTJrzM0AQKsu_5k134s')::extensions.http_header ], null, null ) ) x, lateral ( select ((row_to_json(x) -> 'content') #>> '{}')::json -> 0 ) resp(contents); create extension "supabase-dbdev"; select dbdev.install('supabase-dbdev'); drop extension if exists "supabase-dbdev"; create extension "supabase-dbdev"; -- Install test helpers select dbdev.install('basejump-supabase_test_helpers'); create extension if not exists "basejump-supabase_test_helpers" version '0.0.6'; -- Verify setup with a no-op test begin; select plan(1); select ok(true, 'Pre-test hook completed successfully'); select * from finish(); rollback; ``` -------------------------------- ### supabase bootstrap Source: https://supabase.com/llms/cli.txt Bootstrap a Supabase project from a starter template. ```APIDOC ## POST /llmstxt/supabase_llms_txt/bootstrap ### Description Bootstrap a Supabase project from a starter template. ### Method POST ### Endpoint /llmstxt/supabase_llms_txt/bootstrap ### Parameters #### Path Parameters - **template** (string) - Required - The starter template to use for bootstrapping. #### Query Parameters None #### Request Body None ### Request Example ```bash supabase bootstrap