Skip to content

Instantly share code, notes, and snippets.

@floatdrop floatdrop/app.js
Last active Aug 29, 2015

Embed
What would you like to do?
Refactoring Tools!
// Disclaimer: пример намеренно упрощен
var app = express();
app.get('/user/:id', function (req, res, next) {
if (req.params.id === '31337') {
res.send('Hello eleet!');
return;
}
res.send('Hello user!');
});
// After refactoring
var app = express();
function validate(req, res, next) {
if (req.params.id === '31337') {
res.send('Hello eleet!');
return;
}
}
app.get('/user/:id', function (req, res, next) {
validate(req, res, next);
res.send('Hello user!'); // BOOM! 2 часа искали в коде
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.