19copied
RLS policy template for owner-only tables
alter table your_table enable row level security;
12copied
Keep the Supabase service role key out of the browser bundle
// lib/supabase/admin.ts
import "server-only";10copied
An updated_at column that is always correct
alter table posts
add column if not exists updated_at timestamptz not null default now();9copied
Fail the boot when an environment variable is missing
// lib/env.ts
import { z } from "zod";13copied
Query to find tables without RLS in Supabase
select schemaname, tablename
from pg_tables11copied
Verify a Supabase token in FastAPI as a dependency
# auth.py
import os8copied
Find the missing index behind a slow list query
-- 1. Find the slow ones (enable the pg_stat_statements extension first)
select calls, round(mean_exec_time::numeric, 1) as avg_ms, query17copied
Stripe webhook handler that verifies the signature correctly (Next.js App Router)
import Stripe from "stripe";
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);9copied
Server-side proxy for a third-party API key (Next.js route handler)
// app/api/ai/route.ts
import { NextResponse } from "next/server";8copied
Next.js middleware that protects routes and keeps the session fresh
// middleware.ts
import { createServerClient } from "@supabase/ssr";7copied
Rate limit a route handler with Postgres and no extra service
create table if not exists rate_hits (
key text not null,7copied
Playwright smoke test for magic-link login
// tests/login.spec.ts
import { test, expect } from "@playwright/test";6copied
GitHub Actions job that runs typecheck, lint and tests on every pull request
# .github/workflows/ci.yml
name: ci10copied
Firestore rules: owner-only documents
rules_version = '2';
service cloud.firestore {5copied
Storage bucket policies so users only reach their own files
insert into storage.buckets (id, name, public)
values ('avatars', 'avatars', false)6copied
ruff config that blocks swallowed exceptions
# pyproject.toml
[tool.ruff.lint]4copied
Cold-start warmer as a Vercel cron
// vercel.json
{ "crons": [{ "path": "/api/warm", "schedule": "*/10 * * * *" }] }