Skip to content

Eutychus-Kimutai/go-server

Repository files navigation

Chirpy Go Server

A small Go + PostgreSQL backend for a Chirp-style API with JWT auth, refresh tokens, webhook-based user upgrades, and basic admin metrics.

Tech Stack

  • Go (net/http)
  • PostgreSQL (lib/pq)
  • SQLC-generated queries (internal/database)
  • JWT + refresh-token auth

Requirements

  • Go 1.25+
  • PostgreSQL
  • Optional: sqlc (if regenerating DB code)

Environment Variables

Create a .env file in the project root:

  • DB_URL — Postgres connection string
  • SECRET_KEY — key used to sign/validate JWTs
  • POLKA_KEY — API key for /api/polka/webhooks

Run Locally

  1. Create the database schema from files in sql/schema/.
  2. (Optional) Regenerate SQLC code:
    • sqlc generate
  3. Start the server:
    • go run .

Server runs on http://localhost:8080.

API Routes

  • GET /api/healthz
  • POST /api/users
  • POST /api/login
  • PUT /api/users
  • POST /api/refresh
  • POST /api/revoke
  • POST /api/chirps
  • GET /api/chirps
  • GET /api/chirps/{id}
  • DELETE /api/chirps/{chirpID}
  • POST /api/polka/webhooks

Admin & Static

  • GET /admin/metrics
  • POST /admin/reset
  • GET /app/* serves static files from project root

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors