To run the server locally, run:
npm start
Creates a user
-
URL
/signup
-
Method:
POST
-
URL Body
Required:
username: <String>
password: <String>
accessCode: <String>
-
Success Response:
- Code: 200
Content:
{ jwt: <String>, user: { _id: <String>, username: <String> } }
- Code: 200
-
Error Response:
- Code: 400 BAD REQUEST
Content:
{ errors : [ "DUPLICATE_USERNAME", "INVALID_ACCESS_CODE", "INVALID_PASSWORD" ] }
- Code: 400 BAD REQUEST
Grant session to a user given the username and password
-
URL
/login
-
Method:
POST
-
URL Body
Required:
username: <String>
password: <String>
-
Success Response:
- Code: 200
Content:
{ jwt: <String>, user: { _id: <String>, username: <String> } }
- Code: 200
-
Error Response:
- Code: 400 BAD REQUEST
Content:
{ errors : [ "INVALID_CREDENTIALS" ] }
- Code: 400 BAD REQUEST
Get posts for app feed
-
URL
/posts
-
Method:
GET
-
URL HEADER
Required:
Authorization: "Bearer ${jwt}"
-
Success Response:
- Code: 200
Content:
[ { _id: <String>, tite: <String>, body: <String>, userType: enum { patient, doctor }, private: <Boolean> comments: [ { _id: [included: if userType == doctor] , userType: enum { patient, doctor }, body: <String>, }, ... ] }, ... ]
- Code: 200
-
Error Response:
- Code: 403 UNAUTHORIZED
Content:
{ errors : [ "UNAUTHORIZED", "SESSION_EXPIRED" ] }
- Code: 403 UNAUTHORIZED
Make a new post
-
URL
/posts
-
Method:
POST
-
URL HEADER
Required:
Authorization: "Bearer ${jwt}"
-
URL Body
Required:
title: <String>
body: <String>
Optional:
private: <Boolean>
-
Success Response:
- Code: 200
Content:
{ _id: <String>, tite: <String>, body: <String>, userType: enum { patient, doctor }, private: <Boolean> comments: [] }
- Code: 200
-
Error Response:
-
Code: 400 BAD REQUEST
Content:
{ errors : [ "EMPTY_TITLE", "EMPTY_BODY" ] }
-
Code: 403 UNAUTHORIZED
Content:
{ errors : [ "UNAUTHORIZED", "SESSION_EXPIRED" ] }
-
-
INTERNAL SERVER ERROR
happens when there is something wrong with the server internally- Code: 500
Content:
{ errors : [ "INTERNAL_SERVER_ERROR" ] }
- Code: 500
-
NOT FOUND
happens the URL does not exist- Code: 400
Content:
{ errors : [ "NOT_FOUND" ] }
- Code: 400