NgallaJuke / Glance-Backend

Backend- Tailors Social Media App
6 stars 0 forks source link

Uniform json response #13

Open babacarcissedia opened 3 years ago

babacarcissedia commented 3 years ago

Scope

Right now the shape of the response changes depending on the page we're in. That can be avoided by having a same json schema for the api responses.

Context: https://github.com/NgallaJuke/Glance-Backend/blob/b934ac8b700ec263b7bb11c28a8b6302b4ac2d58/controllers/user.js#L38 https://github.com/NgallaJuke/Glance-Backend/blob/b934ac8b700ec263b7bb11c28a8b6302b4ac2d58/controllers/user.js#L68

Technical directions

{
  type: 'success|error|warning',
  message: string,
  data: {} | []
}
NgallaJuke commented 3 years ago

Indeed. I though about this issue when I was making the HandleRequest utile on the frontend side ! Going the way you suggest here will help a lot for guards rails on the client side. I Will update it soon.