Expanding on Marius’s answer, you can provide the regex AND the parameter name:
app.get('/:id(\\d+)/', function (req, res){
// req.params.id is now defined here for you
});
More Related Contents:
- Passing route control with optional parameter after root in express?
- In express how do I redirect a user to an external url?
- Express Router undefined params with router.use when split across files
- Push items into mongo array via mongoose
- How to share sessions with Socket.IO 1.x and Express 4.x?
- How can I set NODE_ENV=production on Windows?
- What does body-parser do with express?
- How to include route handlers in multiple files in Express? [duplicate]
- How to redirect 404 errors to a page in ExpressJS?
- Node/Express file upload
- npm WARN package.json: No repository field
- socket.io and session?
- Order of router precedence in express.js
- How to modify the nodejs request default timeout time?
- What is the difference between res.end() and res.send()?
- Express next function, what is it really for?
- How can I get Express to output nicely formatted HTML?
- Redirecting to previous page after authentication in node.js using passport.js
- Difference between app.all(‘*’) and app.use(‘/’)
- Mongoose update without callback
- What does middleware and app.use actually mean in Expressjs?
- Uploading images using Node.js, Express, and Mongoose
- POST request not allowed – 405 Not Allowed – nginx, even with headers included
- Use a variable in a Jade include
- How to send a pdf file from Node/Express app to the browser
- What is best way to handle global connection of Mongodb in NodeJs
- Call a “local” function within module.exports from another function in module.exports?
- Model.find() returns empty in mongoose [duplicate]
- Passing arguments to require (when loading module)
- Node.js – logging / Use morgan and winston