Categorygithub.com/DimRev/chirpy
modulepackage
0.0.0-20240502193607-8597f8c24665
Repository: https://github.com/dimrev/chirpy.git
Documentation: pkg.go.dev

# README

Chirpy

This is a tut project via boot.dev learning learning go by building a go REST API server.

APIs

Health check

GET /api/healthz

Responds with a 200 status if the server is running

Chirps

POST /api/chirps

Request header:

"Authorization":"Bearer ${Token}"

Request body:

{ "body": "This is a chirp" }

Responds with:

{
  "id": 1,
  "body": "This is a chirp",
  "author_id": 2
}

GET /api/chirps

Request Search Params 200:

  • author_id - filter by author id
  • sort - "asc" | "desc", ascending or descending order
  • api/chirps?author_id=1&sort=desc

Responds with:

[
  {
    "id": 1,
    "body": "This is a chirp",
    "author_id": 2
  },...
]

GET /api/chirps/{id}

Responds with:

{
  "id": 1,
  "body": "This is a chirp",
  "author_id": 2
}

DELETE /api/chirps

Request header:

"Authorization":"Bearer ${Token}"

Resound with 200

Users

POST /api/users

Request body:

{
  "email": "[email protected]",
  "password": "123123"
}

Responds with:

{
  "email": "[email protected]",
  "id": 1,
  "is_chirp_red": false
}

PUT /api/users

Request header:

"Authorization":"Bearer ${Token}"

Request body:

{
  "email": "[email protected]",
  "password": "123123"
}

Responds with:

{
  "email": "[email protected]",
  "id": 1,
  "is_chirp_red": false
}

Auth

POST /api/login

Request body:

{
  "email": "[email protected]",
  "password": "123123"
}

Responds with:

{
  "email": "[email protected]",
  "id": 1,
  "is_chirp_red": false,
  "token": "{token}",
  "refresh_token": "{refresh_token}"
}

POST /api/refresh

Request header:

"Authorization":"Bearer ${Token}"

Responds with:

{
  "token": "{token}"
}

POST /api/revoke

Request header:

"Authorization":"Bearer ${Token}"

Responds with 200

POST /api/polka/webhook

Request header:

"Authorization":"ApiKey ${Token}"

Responds with:

{
  "id": 1,
  "email": "[email protected]",
  "is_chirp_red": true
}

Deprecated

POST /api/validate_chirp (Deprecated)

.Env

JWT_SECRET=""
POLKA_API_KEY=""

# Constants

No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author