I have end-points like below:
app.post(api + '/channels/:channel_id/albums', user.ensureAuthenticated, album.create);
app.get(api + '/channels/:channel_id/albums/published', user.ensureAuthenticated,album.publishedAlbums);
app.get(api + '/channels/:channel_id/albums', user.ensureAuthenticated, album.findAll);
It all works fine, but it's annoying for me to put user.ensureAuthenticated in each of the end-points, are there any method that you can once put the user.ensureAuthentication at once for all?
For ex: Laravel has such options like beforeAuth you make an if and inside that u put all the end-points that you want to make protected.
like for ex:
if(user.ensureAuthenticated){
// endpoints declariations
}else{
// redirect to login
}
Thanx