39 lines
982 B
JavaScript
39 lines
982 B
JavaScript
var util = {
|
|
debug: false,
|
|
inherits: function(ctor, superCtor) {
|
|
ctor.super_ = superCtor;
|
|
ctor.prototype = Object.create(superCtor.prototype, {
|
|
constructor: {
|
|
value: ctor,
|
|
enumerable: false,
|
|
writable: true,
|
|
configurable: true
|
|
}
|
|
});
|
|
},
|
|
extend: function(dest, source) {
|
|
source = source || {};
|
|
for(var key in source) {
|
|
if(source.hasOwnProperty(key)) {
|
|
dest[key] = source[key];
|
|
}
|
|
}
|
|
return dest;
|
|
},
|
|
randomId: function () {
|
|
return (Math.random().toString(36) + '0000000000000000000').substr(2, 16);
|
|
},
|
|
prettyError: function (msg) {
|
|
console.log('ERROR PeerServer: ', msg);
|
|
},
|
|
allowCrossDomain: function(req, res, next) {
|
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
res.setHeader('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
|
|
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
|
|
|
|
next();
|
|
}
|
|
};
|
|
|
|
module.exports = util;
|