You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const{ send }=require('micro')const{ router, get }=require('microrouter')constauth=require('../auth-from-somewhere');constwithAuth=(route)=>async(req,res)=>{try{awaitauth(req);returnroute(req,res);}catch(e){send(res,401,'Ńot allowed');}};consthello=(req,res)=>send(res,200,`Hello ${req.params.who}`)constnotfound=(req,res)=>send(res,404,'Not found route')module.exports=router(get('/hello/:who',withAuth(hello)),get('/*',notfound))
For auth purpose It would be good to be able to pass function to our handler.
This way you can use:
get('/account', auth(account))
instead ofThe text was updated successfully, but these errors were encountered: