- A Twitter-like backend server built in Go following a guide on Boot.Dev making use of JWTs, PostgreSQL database, webhooks, and API keys.
- Create and login to user accounts using email and password authentication.
- Create, edit, view, and delete text-based "chirps" stored in a PostgreSQL database using JWTs.
- Track premium account (Chirpy Red) status using API Key verified webhooks.
- Generate new access tokens using a refresh token.
- Revoke access to refresh tokens.
- View site usage metrics.
- Go 1.22+
- PostgreSQL 15
- Chirpy can be installed using the following command:
go install github.com/TaitA2/Chirpy@latest
- Start the server by running the following command in your terminal:
Chirpy
- Users can be created or logged into with a POST request to the /api/users endpoint in the following format:
REQUEST: {"email": "name@example.com", "password": "password123"}
RESPONSE: {"ID": <"User-UUID">, ""CreatedAt":"<DateTime>","UpdatedAt":"<DateTime>", "email": "name@example.com", "Token": "Access-token", "RefreshToken": "Refresh-token", "IsChirpyRed": false}
- User credentials can be updated with a PUT request to the /api/users endpoint in the following format:
REQUEST: {"email": "newemail@example.com", "password": "newpassword123"} HEADER: "Authorization: Bearer <Access-Token>"
RESPONSE: {"ID": <"User-UUID">, "CreatedAt":"<DateTime>","UpdatedAt":"<DateTime>", "email": "name@example.com", "Token": "Access-token", "RefreshToken": "Refresh-token", "IsChirpyRed": false}
- Users can generate a new access token with a POST request to the /api/refresh endpoint in the following format:
REQUEST: {} HEADER: "Authorization: Bearer <Refresh-Token>"
RESPONSE: {"token": "<Access-Token>"}
- Refresh tokens can be revoked with a POST request to the /api/revoke endpoint in the following format:
REQUEST: {} HEADER: "Authorization: Bearer <Refresh-Token>"
RESPONSE: 204
- NOTE
- Access tokens expire after 1 hour
- Refresh tokens expire after 60 days
- Chirps can be created with a POST request to the /api/chirps endpoint in the following format:
REQUEST: {"body": "body of the chirp"} HEADER: "Authorization: Bearer <Access-Token>"
RESPONSE: {"ID":"<Chirp-UUID>","CreatedAt":"<DateTime>","UpdatedAt":"<DateTime>","Body":"<body of the chirp>","UserID":"<User-UUID>"}
- Chirps can be deleted with a DELETE request to the /api/chirps/{Chirp-UUID} endpoint in the following format:
REQUEST: {} HEADER: "Authorization: Bearer <Access-Token>"
RESPONSE: 204
- Chirps can be viewed with a GET request to the /api/chirps endpoint
- Results can be sorted by creation date with the query:
?sort=<asc/desc>
- Results can be filtered by specific author with the query:
?author=<author-id>
- Results can be sorted by creation date with the query:
- A specific chirp can be viewed with a GET request to the /api/chirps/{Chirp-UUID} endpoint
- Server status can be viewed with a GET request to the /api/healthz endpoint
- Site visitor count can be viewed at the /admin/metrics endpoint
- User database can be reset with a POST request to the /admin/reset endpoint
- A user can be upgraded to a Chirpy Red account with a POST request to the /api/polka/webhooks endpoint in the following format:
REQUEST: {"event": "user.upgraded","data": {"user_id": "<User-UUID"}}} HEADER: "Authorization: Api-Key <API-KEY>