@brown-ds/distribution 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,5 +6,5 @@ Do NOT edit this file directly. Use it as a black box.
6
6
 
7
7
  If you notice any issues with using this file, please contact the TAs.
8
8
  */
9
- const http=require('http'),url=require('url'),log=require('../util/lo'+'g'),serialization=require('../util/se'+'rializatio'+'n');function isValidBody(_0x4c3a39){if(_0x4c3a39['length']===-0x2493+0x1399*0x1+0x10fa)return new Error('No\x20body');try{_0x4c3a39=JSON['parse'](_0x4c3a39);}catch(_0x59b2c1){return _0x59b2c1;}return undefined;}function endRequest(_0x57bcac,_0xf40322){_0x57bcac['end'](serialization['serialize']([_0xf40322]));}const start=function(_0xad6612){const _0x346156=http['createServ'+'er']((_0x2c7bc6,_0x764d1d)=>{if(_0x2c7bc6['method']!=='PUT'){_0x764d1d['end'](serialization['serialize'](new Error('Method\x20not'+'\x20allowed!')));return;}const _0x2cf799=url['parse'](_0x2c7bc6['url'])['pathname'],[,_0x2e70ee,_0x3c26fb,_0x29f792]=_0x2cf799['split']('/');log('[server]\x20g'+'ot\x20request'+'\x20'+_0x2e70ee+'\x20'+_0x3c26fb+':'+_0x29f792+'\x20from\x20'+_0x2c7bc6['connection']['remoteAddr'+'ess']);let _0x6e3a2b=[];_0x2c7bc6['on']('data',_0x5b5087=>{_0x6e3a2b['push'](_0x5b5087);}),_0x2c7bc6['on']('end',()=>{_0x6e3a2b=Buffer['concat'](_0x6e3a2b)['toString']();let _0x3c28d0;if(_0x3c28d0=isValidBody(_0x6e3a2b)){endRequest(_0x764d1d,_0x3c28d0);return;}_0x6e3a2b=JSON['parse'](_0x6e3a2b),_0x6e3a2b=serialization['deserializ'+'e'](_0x6e3a2b);const _0x58fb43=_0x6e3a2b;!Array['isArray'](_0x58fb43)&&endRequest(_0x764d1d,new Error('Invalid\x20ar'+'gument\x20typ'+'e,\x20expecte'+'d\x20array,\x20g'+'ot\x20'+typeof _0x58fb43));const _0x288319=_0x3c26fb;global['distributi'+'on']['local']['routes']['get']({'service':_0x3c26fb,'gid':_0x2e70ee},(_0x54c3b6,_0x250f7c)=>{const _0x3abf4b=(_0x77c04,_0x2cf3f4)=>{_0x764d1d['end'](serialization['serialize']([_0x77c04,_0x2cf3f4]));};if(_0x54c3b6){_0x3abf4b(_0x54c3b6);return;}if(!_0x250f7c[_0x29f792]){_0x3abf4b(new Error('Method\x20'+_0x29f792+('\x20not\x20found'+'\x20in\x20servic'+'e\x20')+_0x288319));return;}log('[server]\x20\x20'+'Calling\x20se'+'rvice:\x20'+_0x288319+':'+_0x29f792+('\x20with\x20args'+':\x20')+JSON['stringify'](_0x58fb43));_0x58fb43['length']===-0x12a9+-0x1*-0x960+0x1*0x94a&&_0x250f7c[_0x29f792]['length']===0x98a*-0x2+-0x27*-0x89+-0x1c8&&_0x58fb43['push'](undefined);try{_0x250f7c[_0x29f792](..._0x58fb43,_0x3abf4b);}catch(_0x5e53a3){_0x3abf4b(_0x5e53a3);}});});});_0x346156['listen'](global['nodeConfig']['port'],global['nodeConfig']['ip'],()=>{log('Server\x20run'+'ning\x20at\x20ht'+'tp://'+global['nodeConfig']['ip']+':'+global['nodeConfig']['port']+'/'),global['distributi'+'on']['node']['server']=_0x346156,_0xad6612(_0x346156);}),_0x346156['on']('error',_0x3b7e44=>{log('Server\x20err'+'or:\x20'+_0x3b7e44);throw _0x3b7e44;});};module['exports']={'start':start};
9
+ const http=require('http'),url=require('url'),log=require('../util/lo'+'g'),serialization=require('../util/se'+'rializatio'+'n');function isValidBody(_0x175148){if(_0x175148['length']===0x540+-0x8*-0x401+-0x2548)return new Error('No\x20body');try{_0x175148=JSON['parse'](_0x175148);}catch(_0x2f1a42){return _0x2f1a42;}return undefined;}function endRequest(_0x24502b,_0x56db04){_0x24502b['end'](serialization['serialize']([_0x56db04]));}const start=function(_0x22ef28){const _0x2a061d=http['createServ'+'er']((_0x23b90e,_0x15816c)=>{if(_0x23b90e['method']!=='PUT'){_0x15816c['end'](serialization['serialize'](new Error('Method\x20not'+'\x20allowed!')));return;}const _0x235830=url['parse'](_0x23b90e['url'])['pathname'],[,_0xfd1c82,_0x2e4af7,_0x5bf34b]=_0x235830['split']('/');log('[server]\x20g'+'ot\x20request'+'\x20'+_0xfd1c82+'\x20'+_0x2e4af7+':'+_0x5bf34b+'\x20from\x20'+_0x23b90e['connection']['remoteAddr'+'ess']);let _0x18ed27=[];_0x23b90e['on']('data',_0x593970=>{_0x18ed27['push'](_0x593970);}),_0x23b90e['on']('end',()=>{_0x18ed27=Buffer['concat'](_0x18ed27)['toString']();let _0x5cf18f;if(_0x5cf18f=isValidBody(_0x18ed27)){endRequest(_0x15816c,_0x5cf18f);return;}_0x18ed27=JSON['parse'](_0x18ed27),_0x18ed27=serialization['deserializ'+'e'](_0x18ed27);const _0x1497d3=_0x18ed27;!Array['isArray'](_0x1497d3)&&endRequest(_0x15816c,new Error('Invalid\x20ar'+'gument\x20typ'+'e,\x20expecte'+'d\x20array,\x20g'+'ot\x20'+typeof _0x1497d3));const _0xc071a0=_0x2e4af7;global['distributi'+'on']['local']['routes']['get']({'service':_0x2e4af7,'gid':_0xfd1c82},(_0x1fbece,_0x12f4d1)=>{const _0x56148b=(_0x8d5f4b,_0x2d5fe7)=>{_0x15816c['end'](serialization['serialize']([_0x8d5f4b,_0x2d5fe7]));};if(_0x1fbece){_0x56148b(_0x1fbece);return;}if(!_0x12f4d1[_0x5bf34b]){_0x56148b(new Error('Method\x20'+_0x5bf34b+('\x20not\x20found'+'\x20in\x20servic'+'e\x20')+_0xc071a0));return;}log('[server]\x20\x20'+'Calling\x20se'+'rvice:\x20'+_0xc071a0+':'+_0x5bf34b+('\x20with\x20args'+':\x20')+JSON['stringify'](_0x1497d3));_0x1497d3['length']===0xcb3*-0x1+-0x2702*-0x1+0x7*-0x3c2&&_0x12f4d1[_0x5bf34b]['length']===-0xadf+-0x92c*0x2+0x1d3a&&_0x1497d3['push'](undefined);try{_0x12f4d1[_0x5bf34b](..._0x1497d3,_0x56148b);}catch(_0x4def7f){_0x56148b(_0x4def7f);}});});});_0x2a061d['listen'](global['nodeConfig']['port'],global['nodeConfig']['ip'],()=>{log('Server\x20run'+'ning\x20at\x20ht'+'tp://'+global['nodeConfig']['ip']+':'+global['nodeConfig']['port']+'/'),global['distributi'+'on']['node']['server']=_0x2a061d,_0x22ef28(_0x2a061d);}),_0x2a061d['on']('error',_0x285242=>{log('Server\x20err'+'or:\x20'+_0x285242);throw _0x285242;});};module['exports']={'start':start};
10
10
  /* eslint-enable */
@@ -6,5 +6,5 @@ Do NOT edit this file directly. Use it as a black box.
6
6
 
7
7
  If you notice any issues with using this file, please contact the TAs.
8
8
  */
9
- const fs=require('fs'),path=require('path'),logFile=path['join'](__dirname,'../../','log.txt');function log(_0x2b5c3c,_0x5e5b18){_0x5e5b18===undefined&&(_0x5e5b18='info');const _0x365d46=new Date(),_0x117db9=new Intl['DateTimeFo'+'rmat']('en-GB',{'day':'2-digit','month':'2-digit','year':'numeric','hour':'2-digit','minute':'2-digit','second':'2-digit','hour12':![]})['format'](_0x365d46)+'.'+String(_0x365d46['getMillise'+'conds']()*(-0x1b0d+-0x144+0x2039))['padStart'](-0x7f3*-0x4+-0x611+-0x19b5,'0');global['distributi'+'on']['local']['status']['get']('sid',(_0x1cac62,_0xcb04d3)=>{fs['appendFile'+'Sync'](logFile,_0x117db9+'\x20['+global['nodeConfig']['ip']+':'+global['nodeConfig']['port']+'('+_0xcb04d3+')]\x20['+_0x5e5b18+']\x20'+_0x2b5c3c+'\x0a');});}module['exports']=log;
9
+ const fs=require('fs'),path=require('path'),logFile=path['join'](__dirname,'../../','log.txt');function log(_0x145967,_0x512029){_0x512029===undefined&&(_0x512029='info');const _0x4b9050=new Date(),_0x380d91=new Intl['DateTimeFo'+'rmat']('en-GB',{'day':'2-digit','month':'2-digit','year':'numeric','hour':'2-digit','minute':'2-digit','second':'2-digit','hour12':![]})['format'](_0x4b9050)+'.'+String(_0x4b9050['getMillise'+'conds']()*(-0x6*0x4da+-0x4*-0x16+0x20ac))['padStart'](-0x304+-0x6*-0x26e+-0xb8a,'0');fs['appendFile'+'Sync'](logFile,_0x380d91+'\x20['+global['nodeConfig']['ip']+':'+global['nodeConfig']['port']+'('+global['moreStatus']['sid']+')]\x20['+_0x512029+']\x20'+_0x145967+'\x0a');}module['exports']=log;
10
10
  /* eslint-enable */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brown-ds/distribution",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "A library for building distributed systems.",
5
5
  "main": "distribution.js",
6
6
  "useLibrary": false,