hack4impact-uiuc / h4i-recruitment

H4I recruitment platform
https://h4i-recruitment.vercel.app
17 stars 3 forks source link

Standardize Backend Endpoint Responses with middleware #69

Open tko22 opened 6 years ago

tko22 commented 6 years ago

Our REST API Spec Have responses follow this format.

{
  "code": 200, 
  "message": "", 
  "result": {}, 
  "success": true
}

whenever you are editing an endpoint or adding one, standardize it's response. errorWrap catches all errors and returns a specific error response so no need to handle errors in endpoints, unless you want a specific message to be given to the client. This issue will be ongoing until all current endpoints responses have been standardized.

tko22 commented 6 years ago

we could make an express middleware for this instead.

tko22 commented 5 years ago

we do the same thing with flask-boilerplate with create_response https://github.com/tko22/flask-boilerplate/blob/88b9077dad74e7dd30404adffb2bf3ec2cc0bb2e/api/core.py#L27-L50

at least stick to this convention when making new endpoints...