Finish refactoring api

This commit is contained in:
calzoneman 2013-08-16 10:37:26 -05:00
parent a20df07515
commit f523649f54
2 changed files with 18 additions and 5 deletions

17
api.js
View File

@ -499,10 +499,19 @@ module.exports = function (Server) {
return; return;
} }
var channels = Server.db.listUserChannels(name); db.listUserChannels(name, function (err, res) {
res.jsonp({ if(err) {
success: true, res.jsonp({
channels: channels success: false,
channels: []
});
return;
}
res.jsonp({
success: true,
channels: res
});
}); });
}); });

View File

@ -1,6 +1,10 @@
module.exports = { module.exports = {
isValidChannelName: function (name) { isValidChannelName: function (name) {
return name.match(/^[\w-_]+$/); return name.match(/^[\w-_]{1,30}$/);
},
isValidUserName: function (name) {
return name.match(/^[\w-_]{1,20}$/);
}, },
randomSalt: function (length) { randomSalt: function (length) {