repositorypackage
0.0.0-20240527115257-35f11804c88b
Repository: https://github.com/delvoid/chirpy.git
Documentation: pkg.go.dev
# Packages
No description provided by the author
# README
Chirpy
Chirpy is a simple RESTful API built with Go that allows users to create, read, update, and delete "chirps" (short messages) and manage their user accounts.
Features
- User authentication and authorization with JSON Web Tokens (JWT)
- Create, read, update, and delete chirps
- Filter chirps by author
- Sort chirps by ID in ascending or descending order
- Create and manage user accounts
- Upgrade users to "Chirpy Red" membership
- Webhook integration for handling user upgrades from payment providers
Getting Started
Prerequisites
- Go (version 1.16 or later)
- An environment with the following environment variables set:
JWT_SECRET
: A secret key used for signing and verifying JSON Web TokensPOLKA_API_KEY
: An API key provided by the Polka payment provider for handling webhooks
Installation
- Clone the repository:
git clone https://github.com/your-username/chirpy.git
- Navigate to the project directory:
cd chirpy
- Build and run the server:
go build -o out && ./out
To clear the database before starting the server, you can use the --debug
flag
The server should now be running on http://localhost:8080
.
Usage
The Chirpy API provides the following endpoints:
POST /api/users
: Create a new user accountPOST /api/login
: Authenticate a user and obtain a JWTPUT /api/users
: Update a user's email or passwordPOST /api/chirps
: Create a new chirpGET /api/chirps
: Retrieve all chirps or filter by authorGET /api/chirps/{chirpID}
: Retrieve a single chirp by IDDELETE /api/chirps/{chirpID}
: Delete a chirp (requires authentication)POST /api/polka/webhooks
: Handle webhooks from the Polka payment provider for user upgrades