Getting Started
Prerequisites
- Node.js 20+ and pnpm
- A Supabase project (free tier works)
- The Supabase CLI (for migrations and local dev)
Clone and Install
git clone https://github.com/vidluther/linkblog.git
cd linkblog
pnpm install
Environment Variables
Create a .env file in the project root:
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key
API_KEY=a-secret-key-for-write-endpoints
PORT=3000
| Variable | Description |
|---|---|
SUPABASE_URL |
Your Supabase project URL |
SUPABASE_ANON_KEY |
Supabase anonymous/public key |
API_KEY |
Protects write endpoints via x-api-key header |
PORT |
Server port (defaults to 3000) |
Database Setup
The Supabase migration creates the links table automatically.
# Link to your Supabase project
npx supabase link --project-ref your-project-ref
# Run migrations
npx supabase db push
To seed the database with sample data:
npx supabase db reset
This runs supabase/seed.sql which inserts a handful of example links.
Run Locally
# Development (with hot reload)
pnpm start:dev
# Production build
pnpm build
pnpm start:prod
The API will be available at http://localhost:3000.
Run Tests
# Unit tests
pnpm test
# Watch mode
pnpm test:watch
# Coverage
pnpm test:cov
# End-to-end tests
pnpm test:e2e
Lint and Format
# Lint
pnpm lint
# Lint with auto-fix
pnpm lint:fix
# Format check
pnpm fmt:check
# Format
pnpm fmt
Verify It Works
Once the server is running:
# Health check
curl http://localhost:3000/health
# List links (requires API key)
curl -H "x-api-key: your-api-key" http://localhost:3000/links
# RSS feed (public)
curl http://localhost:3000/feed
Next: API Reference