-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
32 lines (26 loc) · 718 Bytes
/
main.js
File metadata and controls
32 lines (26 loc) · 718 Bytes
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
'use strict';
module.exports = function() {
var httpStatusCodes = require('./httpStatusCodes');
function ResponseMessage(status, body) {
this.status = status;
this.body = body || {};
};
ResponseMessage.prototype.toString = function() {
return JSON.stringify(this);
};
function Response(name) {
return function(body) {
return new ResponseMessage(httpStatusCodes[name], body);
};
};
var responses = {};
var response;
for (var status in httpStatusCodes) {
if (httpStatusCodes.hasOwnProperty(status)) {
response = Response(status);
responses[status] = response;
responses[httpStatusCodes[status].code] = response;
}
}
return responses;
}();