Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document endpoints in README #56

Open
nicmart-dev opened this issue Jun 12, 2024 · 1 comment
Open

Document endpoints in README #56

nicmart-dev opened this issue Jun 12, 2024 · 1 comment

Comments

@nicmart-dev
Copy link
Owner

No description provided.

@nicmart-dev
Copy link
Owner Author

Example provided by BrainStation:

Endpoints

GET /cafes

  • Get cafés, with an optional "visited" if the user is logged in or not

Parameters:

  • longitude: User-provided location as a number
  • latitude: User-provided location as a number
  • token (optional): JWT used to add "visited" boolean

Response:

[
    {
        "id": 1,
        "name": "Quantum Coffee",
        "distance": 0.25,
        "averageRating": 4.5,
        "visited": true
    },
    ...
]

GET /cafes/:id

  • Get café by id, with an optional "userRating" if the user is logged in or not

Parameters:

  • id: Café id as number
  • token (optional): JWT used to add user rating

Response:

{
    "id": 1,
    "name": "Quantum Coffee",
    "distance": 0.25,
    "averageRating": 4.5,
    "userRating": 5
}

POST /cafes/:id/rating

  • Logged in user can add their rating of a café

Parameters:

  • id: Café id
  • token: JWT of the logged in user
  • rating: Number Rating out of 5 in 0.5 increments

Response:

{
    "id": 1,
    "name": "Quantum Coffee",
    "distance": 0.25,
    "averageRating": 4.5,
    "userRating": 5
}

PUT /cafes/:id/rating

  • Logged in user can update their rating of a café

Parameters:

  • id: Café id
  • token: JWT of the logged in user
  • rating: Number Rating out of 5 in 0.5 increments

Response:

{
    "id": 1,
    "name": "Quantum Coffee",
    "distance": 0.25,
    "averageRating": 4.5,
    "userRating": 5
}

POST /users/register

  • Add a user account

Parameters:

  • email: User's email
  • password: User's provided password

Response:

{
    "token": "seyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6I..."
}

POST /users/login

  • Login a user

Parameters:

  • email: User's email
  • password: User's provided password

Response:

{
    "token": "seyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6I..."
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready
Development

No branches or pull requests

1 participant