Skip to content

Latest commit

 

History

History
204 lines (148 loc) · 2.58 KB

API.markdown

File metadata and controls

204 lines (148 loc) · 2.58 KB

Peer Rating App API Documentation

Base URL

http://localhost:3000

Endpoints

1. Register User

Endpoint: /auth/register

Method: POST

Request Body:

{
  "username": "string",
  "password": "string"
}

Response:

{
  "message": "User registered"
}

cURL Request:

curl -X POST http://localhost:3000/auth/register \
-H "Content-Type: application/json" \
-d '{
  "username": "john_doe",
  "password": "password123"
}'

2. Login User

Endpoint: /auth/login

Method: POST

Request Body:

{
  "username": "string",
  "password": "string"
}

Response:

{
  "token": "jwt_token"
}

cURL Request:

curl -X POST http://localhost:3000/auth/login \
-H "Content-Type: application/json" \
-d '{
  "username": "john_doe",
  "password": "password123"
}'

3. Rate a Peer

Endpoint: /ratings/rate

Method: POST

Headers:

Authorization: Bearer jwt_token
Content-Type: application/json

Request Body:

{
  "rateeId": "string",
  "rating": "number",
  "feedback": "string"
}

Response:

{
  "message": "Rating submitted"
}

cURL Request:

curl -X POST http://localhost:3000/ratings/rate \
-H "Authorization: Bearer jwt_token" \
-H "Content-Type: application/json" \
-d '{
  "rateeId": "user_id",
  "rating": 4,
  "feedback": "Great work!"
}'

4. Get Feedback for a User

Endpoint: /ratings/feedback/:userId

Method: GET

Headers:

Authorization: Bearer jwt_token

Response:

[
  {
    "rater": {
      "_id": "string",
      "username": "string"
    },
    "ratee": "string",
    "rating": "number",
    "feedback": "string"
  }
]

cURL Request:

curl -X GET http://localhost:3000/ratings/feedback/user_id \
-H "Authorization: Bearer jwt_token"

5. Get List of Users

Endpoint: /users/list

Method: GET

Response:

[
  {
    "_id": "string",
    "username": "string",
    "averageRating": "number"
  }
]

cURL Request:

curl -X GET http://localhost:3000/users/list

6. Get User Profile

Endpoint: /users/profile/:userId

Method: GET

Response:

{
  "_id": "string",
  "username": "string",
  "averageRating": "number"
}

cURL Request:

curl -X GET http://localhost:3000/users/profile/user_id

This documentation should help you interact with your API endpoints effectively. Make sure to replace placeholder values like jwt_token, user_id, and others with actual values.