Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

param_pam_pam could've used app.param #72

Open
grabbou opened this issue May 21, 2015 · 2 comments
Open

param_pam_pam could've used app.param #72

grabbou opened this issue May 21, 2015 · 2 comments

Comments

@grabbou
Copy link

grabbou commented May 21, 2015

It'd be quite cool to show users how they can profit from app.param.

app.param('message_id', function(req, res, next, messageId) {
    req.computedHash = require('crypto')
        .createHash('sha1')
        .update(new Date().toDateString() + messageId)
        .digest('hex')
    next();
});

app.get('/:message_id', function(req, res, next) {
    res.send(req.computedHash);
});

Maybe worth mentioning there are two ways to approach this problem? Showing the beginners not everything needs to be handled in a route handler might be a nice tip!

WDYT?

@grabbou
Copy link
Author

grabbou commented May 21, 2015

(But actually with Express being so unopinionated they can even use general-purpose middleware so mind-fuck guaranteed)

@azat-co
Copy link
Owner

azat-co commented Sep 29, 2015

@grabbou feel free to make a pull request. It's a good idea to show param and general middleware so maybe create both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants