TowerDevs / runnup-server

0 stars 1 forks source link

Change Friends endpoint to REST #49

Closed richardantao closed 4 years ago

richardantao commented 4 years ago

REST for friends would be:

POST /friends (add)

PATCH /friends/:friendId (respond)

PUT /friends/:friendId (manage)

michaelddsilva commented 4 years ago

I decided to do

POST /friends (add)

PATCH /friends (respond)

PUT /friends(manage)

because we'd want the friend ids to not be exposed

richardantao commented 4 years ago

How are you accessing the id?

michaelddsilva commented 4 years ago

it's all handled in the controller:

since the friendrequests and friends will be associated with the requestor/friend's id I was thinking they would be passed in res.body

exports.friend_respond = (req, res) => {

    const { requestor, response } = req.body;

    ...

}
exports.friend_manage = (req, res) => {

    const { friend, decision } = req.body;

    ...

}