Skip to content

Instantly share code, notes, and snippets.

@simenbrekken
Created August 24, 2011 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simenbrekken/1168410 to your computer and use it in GitHub Desktop.
Save simenbrekken/1168410 to your computer and use it in GitHub Desktop.
Keep it Suntory™ DRY
var getStructure = function(req, res, next) {
db.findOne({name: req.params.name}, function(err, result) {
res.json(result);
});
}
app.get('/structure/:name', getStructure);
app.post('/structure/:name/save', function(req, res, next) {
var structure = req.body;
db.save(structure, function(err, result) {
next();
});
}, getStructure);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment