Skip to content

Commit

Permalink
missing add utils helper
Browse files Browse the repository at this point in the history
  • Loading branch information
hengkiardo committed Sep 5, 2014
1 parent 8429d3e commit eb693f1
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/helper/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

exports.randomString = function (length) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHUJKLMNOPQRSTUVWXYZ';
var result = '';
for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))];
return result;
}

exports.prettyJSON = function(data) {
return require("prettyjson").render(data);
}

exports.responses = function(res, status, obj) {
var resultPrint = {}
if (status == 200) {
resultPrint.data = obj
} else {
resultPrint = obj
}
resultPrint.id = require('node-uuid').v4()
resultPrint.status = status

return res.status(status).json(resultPrint )
}

0 comments on commit eb693f1

Please sign in to comment.