is it possible to name routes in Express.js

前端 未结 4 1257
[愿得一人]
[愿得一人] 2020-12-16 00:09

Basic route is like this:

app.get(\'/\', function(req, res){
  res.send(\'hello world\');
});

Is it possible to name that route and have it

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-16 00:38

    Another option that I don't see here is to just extract the route function out with a function name. If all you are trying to do is writing self-documenting code.

    function updateToDo(req, res, next) { /*do router stuff*/};
    router.put('/', updateToDo);
    

提交回复
热议问题