@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(
|
|
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 */
|
package/distribution/util/log.js
CHANGED
|
@@ -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(
|
|
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 */
|