Chirpy is a simple social media application where users can post short messages called "chirps". This project demonstrates a basic web application built with Go, PostgreSQL, and various other technologies.
- User authentication and authorization
- Create, read, update, and delete chirps
- Fetch chirps by user ID
- Sort chirps in ascending or descending order
- Webhooks for handling external events
- Go 1.16 or later
- PostgreSQL 12 or later
goose
for database migrationssqlc
for generating type-safe Go code from SQL queries
git clone git@github.com:andersonfpcorrea/Chirpy.git
cd Chirpy
Create a .env file in the root directory of the project and add the following environment variables:
DB_URL=postgres://username:password@localhost:5432/chirpy?sslmode=disable
PLATFORM=dev
JWT_SECRET=your_jwt_secret
POLKA_KEY=your_polka_key
go mod tidy
Setup your Postgres, then run migrations with goose
:
goose -dir ./sql/schema postgres "postgres://username:password@localhost:5432/chirpy" up
sqlc generate
go run .
The server will start on http://localhost:8080.
- POST /api/users: Create a new user
- PUT /api/users: Update user email and password
- POST /api/refresh: Refresh JWT token
- POST /api/revoke: Revoke refresh token
- POST /api/chirps: Create a new chirp
- GET /api/chirps: Get all chirps (with optional sorting)
- GET /api/chirps/{id}: Get a specific chirp by ID
- DELETE /api/chirps/{id}: Delete a chirp by ID
- POST /api/polka/webhooks: Handle external events from Polka (fake company)