Defaults.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. 'use strict';
  2. /*eslint no-magic-numbers: ["error", { "ignore": [ 0] }]*/
  3. /**
  4. * @module entities
  5. */
  6. const os = require('os');
  7. /**
  8. * @class Defaults
  9. * @description Defaults Entity
  10. */
  11. class Defaults{
  12. /**
  13. * @constructor
  14. * @method constructor
  15. * @return {void}
  16. */
  17. constructor(){
  18. this.appspace='app.';
  19. this.socketRoot='/tmp/';
  20. this.id=os.hostname();
  21. this.encoding='utf8';
  22. this.rawBuffer=false;
  23. this.sync=false;
  24. this.unlink=true;
  25. this.delimiter='\f';
  26. this.silent=false;
  27. this.logDepth=5;
  28. this.logInColor=true;
  29. this.logger=console.log.bind(console);
  30. this.maxConnections=100;
  31. this.retry=500;
  32. this.maxRetries=Infinity;
  33. this.stopRetrying=false;
  34. this.IPType=getIPType();
  35. this.tls=false;
  36. this.networkHost = (this.IPType == 'IPv6') ? '::1' : '127.0.0.1';
  37. this.networkPort = 8000;
  38. this.interface={
  39. localAddress:false,
  40. localPort:false,
  41. family:false,
  42. hints:false,
  43. lookup:false
  44. }
  45. }
  46. }
  47. /**
  48. * method to get ip type
  49. *
  50. * @method getIPType
  51. * @return {string} ip type
  52. */
  53. function getIPType() {
  54. const networkInterfaces = os.networkInterfaces();
  55. let IPType = '';
  56. if (networkInterfaces
  57. && Array.isArray(networkInterfaces)
  58. && networkInterfaces.length > 0) {
  59. // getting the family of first network interface available
  60. IPType = networkInterfaces [
  61. Object.keys( networkInterfaces )[0]
  62. ][0].family;
  63. }
  64. return IPType;
  65. }
  66. module.exports=Defaults;