### Install Project Dependencies (npm) Source: https://github.com/supabase-community/database-build/blob/main/README.md Installs all necessary project dependencies from the monorepo root using npm. This is a prerequisite for running any development or build commands. ```shell npm i ``` -------------------------------- ### Start Development Server (npm run dev) Source: https://github.com/supabase-community/database-build/blob/main/README.md Starts the development server for the entire monorepo using 'npm run dev'. This command leverages 'turbo' to intelligently build and manage dependencies across projects. ```shell npm run dev ``` -------------------------------- ### Start Local Supabase Stack (npx) Source: https://github.com/supabase-community/database-build/blob/main/README.md Starts the local Supabase stack, which includes services like the database, authentication, and storage. This command is essential for local development that relies on Supabase services. ```shell npx supabase start ``` -------------------------------- ### Start Local Redis Containers (docker compose) Source: https://github.com/supabase-community/database-build/blob/main/README.md Starts local Redis containers using Docker Compose. This service is used for rate limiting and exposes an API on port 8080. ```shell docker compose -f ./apps/web/docker-compose.yml up -d ``` -------------------------------- ### Supabase Vault Secret Setup Source: https://github.com/supabase-community/database-build/blob/main/supabase/functions/certificate/README.md This SQL snippet demonstrates how to set up necessary secrets in Supabase Vault. It creates secrets for the Supabase API URL and a shared secret required to trigger the certificate Supabase Edge Function. These secrets are essential for the `pg_cron` job and manual function calls. ```sql select vault.create_secret('', 'supabase_url', 'Supabase API URL'); select vault.create_secret(encode(gen_random_bytes(24), 'base64'), 'supabase_functions_certificate_secret', 'Shared secret to trigger the "certificate" Supabase Edge Function'); ``` -------------------------------- ### Configure KV (Redis) Local Variables (echo) Source: https://github.com/supabase-community/database-build/blob/main/README.md Sets up local environment variables for Key-Value (Redis) store, including API URL and token. These are used for features like rate limiting. ```shell echo 'KV_REST_API_URL="http://localhost:8080"' >> ./apps/web/.env.local echo 'KV_REST_API_TOKEN="local_token"' >> ./apps/web/.env.local ``` -------------------------------- ### Configure Supabase Environment Variables (npx, grep) Source: https://github.com/supabase-community/database-build/blob/main/README.md Retrieves local Supabase URL and anon key using 'npx supabase status' and appends them to the './apps/web/.env.local' file. This is crucial for the web application to connect to the local Supabase instance. ```shell npx supabase status -o env \ --override-name api.url=NEXT_PUBLIC_SUPABASE_URL \ --override-name auth.anon_key=NEXT_PUBLIC_SUPABASE_ANON_KEY | \ grep NEXT_PUBLIC >> ./apps/web/.env.local ``` -------------------------------- ### Configure OpenAI API Key (echo) Source: https://github.com/supabase-community/database-build/blob/main/README.md Appends the OpenAI API key to the './apps/web/.env.local' file. This key is required for the AI assistance features within the web application. ```shell echo 'OPENAI_API_KEY=""' >> ./apps/web/.env.local ``` -------------------------------- ### Deploy Browser Proxy using Fly.io CLI Source: https://github.com/supabase-community/database-build/blob/main/apps/browser-proxy/README.md This command deploys the browser proxy application to Fly.io. Ensure you have configured the necessary environment variables as secrets in your Fly.io application before deployment. ```sh fly deploy --app database-build-browser-proxy ``` -------------------------------- ### Schedule Weekly Certificate Renewal with pg_cron Source: https://github.com/supabase-community/database-build/blob/main/supabase/functions/certificate/README.md This SQL snippet schedules a weekly cron job using `pg_cron` to renew SSL certificates. The job runs every Sunday at midnight and calls the 'certificate' Supabase Edge Function via an HTTP POST request, passing the domain name and authentication token. ```sql select cron.schedule ( 'certificates', -- every Sunday at 00:00 '0 0 * * 0', $$ -- certificate for the browser proxy select net.http_post( url:=(select supabase_url() || '/functions/v1/certificate'), headers:=('{"Content-Type": "application/json", "Authorization": "Bearer " || (select supabase_functions_certificate_secret()) || '"}') :: jsonb, body:='{"domainName": "browser.db.build"}' :: jsonb ) as request_id $$ ); ``` -------------------------------- ### Manually Trigger Certificate Renewal Function Source: https://github.com/supabase-community/database-build/blob/main/supabase/functions/certificate/README.md This SQL snippet shows how to manually trigger the 'certificate' Supabase Edge Function using `net.http_post`. It is used to immediately request or renew an SSL certificate for a specified domain. The function requires authentication via a bearer token obtained from Supabase Vault. ```sql select net.http_post( url:=(select supabase_url() || '/functions/v1/certificate'), headers:=('{"Content-Type": "application/json", "Authorization": "Bearer " || (select supabase_functions_certificate_secret()) || '"}') :: jsonb, body:='{"domainName": "browser.db.build"}' :: jsonb ) as request_id; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.