Chirpy is an API that allows for users to make requests that allow them to make new chirps, update their account, a webhook to upgrade their account, and checks their authorization for certain tasks.
Make sure to have PostgresSQL installed and running on a machine (it does not have to be the same machine that is running Chirpy).
Clone this repository:
git clone https://github.com/avgra3/chirpyCreate a file at the root of the cloned repository called .env. This will contain your environment variables. You will need several parameters:
DB_URL: Something like "postgres://postgres:postgres@localhost:5432/chirpy?sslmode=disable"- This is where you would change the host address if PostgreSQL is running on a different machine.
PLATFORM: options are "dev" and "release"- JWT_SECRET: create your secret using your favorite tool
- POLKA_KEY: Our random key to the webhook which checks for a user's Chirpy Red status.
Now, from your terminal run the buildAndServe.sh from the root directory of the project:
./buildAndServe.sh
It will run all unit tests before running the server. Now you have Chirpy running!
GET /admin/metrics=> Get metrics of the api. Currently, just shows the user if they have authorization, how many times the api has responded to requests.POST /admin/reset=> Truncates all data from theusersandchirpstables. Useful for getting started when trying out the api.- (removed)
POST /api/validate_chirp=> No longer supported. The functionality was to check if a chirp was less than the maximum characters. POST /api/login=> Allow the user to login with ausernameandpassword.POST /api/users=> See all users.POST /api/chirps=> Post a new chirp. Will respond with an error if a user does not have an access token or if the chirp is longer than the 120 character limit. (This inherited the functionality of thePOST /api/validate_chirphttp request.GET /api/chirps=> See all chirps.- Optional parameters:
sort: asc or desc the results by thecreated_atfield.author_id: The UUID of the user who wrote the chirp.
- Optional parameters:
GET /api/chirps/{chirpID}=> Get back a specific chirp by using the chirp's UUID.POST /api/refresh=> Refresh the access token for a user.POST /api/revoke=> Revokes a user's access token.PUT /api/users=> Update a user's username or password.DELETE /api/chirps/{chirpID}=> Delete a chirp. You must be the chirp's author and give the corret chirp id.
POST /api/polka/webhooks=> A webhook to allow a user to upgrade their account to "red", a premium feature.