-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
43 lines (40 loc) · 956 Bytes
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @author: Thomas Stockx
* @copyright: OKFN Belgium
*/
/**
* Creates a json meta representation containing error information
* @param code the error code
* @param an optional more specific error code (no html code)
* @param error message
* @return json representation of input
*/
exports.createErrorMeta = function (code, msg_code, msg_text) {
return (
{
"code": code, "message":
{
"msg_code": msg_code, "msg_text": msg_text
}
}
);
}
/**
* Creates a json meta representation
* @return json representation for 200 OK meta
*/
exports.createOKMeta = function () {
return (
{
"code": 200, "message": {}
}
);
}
/**
* Adds zero in front of 1-digit number
* @param number
* @result number concatted to a zero if it is a 1-digit.
*/
exports.addZero = function(num) {
return (num >= 0 && num < 10) ? "0" + num : num + "";
}