I use Sails and Waterline, and i would compare username in url with database elements for find an user.
http://localhost:1337/johndoe (or id) find John Doe in database.
My controller, for the moment :
user: function (req, res) {
var user = req.param('user');
var elt = (/^[0-9]*$/.test(user))?{id: user}:{name: user};
User.findOne(elt).exec(function (err, user) {
if (err) res.json({ error: 'DB error' }, 500);
if (user) {
res.json(user);
} else {
res.json({ error: 'User not found' }, 404);
}
});
}
An idea, please ?