User Routes
GET /users/current
GET /users/active
GET /users/disactive
GET /users/changePic
Auth Routes
POST /auth/register
POST /auth/login
DELETE /auth/logout
Polls Routes
POST /polls
PUT /polls/:pollId
GET /polls/:pollId
DELETE /polls/:pollId
GET /polls
GET /polls/votable
GET /polls/friends
POST /polls/:pollId/:imageIdx/vote
DELETE /polls/:pollId/:imageIdx/vote
Friends
GET /users/:userId/friends/followers
GET /users/:userId/friends/followings
GET /users/:userId/friends/suggestions?name=<query>
POST /users/:userId/friends/:friendId/follow
DELETE /users/:userId/friends/:friendId/follow
FriendLists
GET /friendLists
POST /friendLists
DELETE friendLists/:listId
PUT /friendLists
To make a certain API endpint only accessible by logged-in users, do the following:
- Navigate to route file
- Import
passport
package - Add
passport.authenticate('jwt', { session: false })
as the second parameter inrouter
function. For example:
router.get("/welcome",
passport.authenticate('jwt', { session: false }),
function(req, res, next) {
...
}
);