Defaults.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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.readableAll = false;
  39. this.writableAll = false;
  40. this.interface={
  41. localAddress:false,
  42. localPort:false,
  43. family:false,
  44. hints:false,
  45. lookup:false
  46. }
  47. }
  48. }
  49. /**
  50. * method to get ip type
  51. *
  52. * @method getIPType
  53. * @return {string} ip type
  54. */
  55. function getIPType() {
  56. const networkInterfaces = os.networkInterfaces();
  57. let IPType = '';
  58. if (networkInterfaces
  59. && Array.isArray(networkInterfaces)
  60. && networkInterfaces.length > 0) {
  61. // getting the family of first network interface available
  62. IPType = networkInterfaces [
  63. Object.keys( networkInterfaces )[0]
  64. ][0].family;
  65. }
  66. return IPType;
  67. }
  68. module.exports=Defaults;