-
Notifications
You must be signed in to change notification settings - Fork 44
API Endpoints
jimwang6012 edited this page Mar 19, 2022
·
28 revisions
TODO: Write short description incl. base URL, firebase auth etc.
Route | Description | Path Parameter | Request Header | Request Payload | Response Payload |
---|---|---|---|---|---|
GET /api/users |
Get the currently signed in User | N/A | firebase token | N/A |
202 Found if success, with {_id: string, first_name: string, last_name: string } or 404 Not Found if user not found |
POST /api/users |
Create/register one user with Firebase and store in db | N/A | firebase token | { first_name: string, last_name: string } |
201 Created if success, with { _id: string, first_name: string, last_name: string } or 400 Bad Request
|
Route | Description | Path Parameter | Request Header | Request Payload | Response Payload |
---|---|---|---|---|---|
GET /api/persons/ |
Get all Persons associated with an authenticated User, can filter with the term param |
N/A | Firebase token | { term: string } |
200 OK if success, with 401 UNAUTHORIZED If User not authenticated |
GET /api/persons/:id |
Get one Person associated with an authenticated User | Person's ID | Firebase token | N/A |
200 OK if success, with 401 UNAUTHORIZED If User not authenticated404 NOT FOUND If Person with this ID not found |
POST /api/persons |
Create one Person and associate it with the given User | N/A | Firebase token |
201 CREATED if successful, with 400 Bad Request If Person could not be created409 Conflict If Person could not be stored in the User |
|
PUT /api/persons/:id |
Update one Person associated with an authenticated User | Person's ID | Firebase token |
204 NO CONTENT if successful, 401 UNAUTHORIZED if user is not logged in or does not exist in the database, 404 NOT FOUND if the Person does not belong to this User or does not exist in the database |
|
DELETE /api/persons/:id |
Deletes one Person associated with an authenticated User | Person's ID | Firebase token | N/A |
200 OK if successful, 401 UNAUTHORIZED if a user is not logged in or does not exist in the database, 409 CONFLICT if there is some inconsistency in the database so User could not be updated or Encounters could not be deleted, 404 NOT FOUND if this Person is not associated with the logged-in User |
Route | Description | Path Parameter | Request Header | Request Payload | Response Payload |
---|---|---|---|---|---|
GET /api/encounters |
Get all Encounters associated with an authenticated User, can filter with the term param |
N/A | Firebase token | { term: string } |
200 OK if success, with |
GET /api/encounters/:id |
Get one Encounter associated with an authenticated User | Encounter ID | Firebase token | N/A |
200 OK if success, with 401 UNAUTHORIZED If User not authenticated404 NOT FOUND If Encounter with this ID not found |
POST /api/encounters |
Create one Encounter and associate it with the given User | N/A | Firebase token |
201 CREATED if successful, with 403 Forbidden If Encounter could not be created409 Conflict If Encounter could not be stored in the User |
|
PUT /api/encounters/:id |
--- | --- | --- | --- | --- |
DELETE /api/ecounters/:id |
Deletes one Encounter associated with an authenticated User | Encounter's ID | Firebase token | N/A |
200 OK if successful, 401 UNAUTHORIZED if a user is not logged in or does not exist in the database, 409 CONFLICT if there is some inconsistency in the database so User or Persons could not be updated, 404 NOT FOUND if this Person is not associated with the logged-in User |
The Basics:
The Team:
The Frontend:
The Backend: