is it possible to name routes in Express.js

前端 未结 4 1261
[愿得一人]
[愿得一人] 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条回答
  •  萌比男神i
    2020-12-16 00:28

    I had the same problem and decided to make a library to help me out.

    Besides not hardcoding your routes, it allows me to build navigation components like breadcrumbs and I can use it server side with express or client side with Backbone or whatever.

    https://github.com/hrajchert/express-shared-routes

提交回复
热议问题