chirpy

command module
v0.0.0-...-b73142c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 16 Imported by: 0

README

Chirpy

Chirpy is twitter-like clone API for sending short messages. This is a guided project is a part of boot.dev program.

API resources

User
Create User

POST /api/users

{
    "email": "example@mail.com",
    "password": "123456"     

}

RESPONSE

{
    "email": "example@mail.com",
    "id": 1,
    "token": "this_is_jwt_token"
}
Update User

PUT /api/users

Header:

{
    "Authorization": "Bearer this_is_jwt_token"
}

Body:

{
    "email": "example@mail.com",
    "id": 1
}

RESPONSE

{
    "email": "example@mail.com",
    "id": 1,
    "token": "this_is_jwt_token"
}
Login User

PUT /api/login

{
    "email": "example@mail.com",
    "password": "123456"
}

RESPONSE

{
    "email": "example@mail.com",
    "id": 1,
    "token": "this_is_access_jwt_token",
    "refresh_token": "this_is_refresh_jwt_token"
}
Tokens
Refresh Token

POST /api/refresh

{
    "Authorization": "Bearer this_is_refresh_jwt_token"
}

RESPONSE

{
    "token": "this_is_a_new_access_jwt_token"
}
Revoke Token

POST /api/revoke

{
    "refresh_token": "this_is_refresh_jwt_token"
}
Chirps (messages)
Post a Chirp

POST /api/chirps

Header:

{
    "Authorization": "Bearer this_is_access_token"
}

Body:

{
    "body": "Write your message here!"
}

RESPONSE

{
    "id": 1,
    "body": "Write your message here!",
    "author_id": 1
}
Get chirps

GET /api/chirps

Available parameters:

author_id: lists chirps from this user sort: sorts chirps in ascending(asc or defauld) or descending(desc) order

Usage: Add to the end of url of api call: /api/chirps?author_id=1&sort=desc

RESPONSE

[

{
    "id": 1,
    "body": "Write your message here!",
    "author_id": 1
},
{
    "id": 2,
    "body": "Second message!",
    "author_id": 1
},

]
Get a singel chirp

GET /api/chirps/{chirpID}

RESPONSE

{
    "id": 1,
    "body": "Write your message here!",
    "author_id": 1
}
Delete a Chirp

POST /api/chirps/{chirpID}

Header:

{
    "Authorization": "Bearer this_is_access_token"
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL