HEX
Server: nginx/1.24.0
System: Linux nowruzgan 6.8.0-57-generic #59-Ubuntu SMP PREEMPT_DYNAMIC Sat Mar 15 17:40:59 UTC 2025 x86_64
User: babak (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/dev/nowruzgan/rest/node_modules/machinepack-redis/machines/create-connection-url.js
module.exports = {
//
//
  friendlyName: 'Create connection URL',
  //
  //
  sync: true,
  //
  //
  description: 'Build a Redis connection URL out of a dictionary of connection options.',
  //
  //
  inputs: {
    //
    host: {
      description: 'The host (IP or domain) on which the Redis server is running.',
      example: '127.0.0.1',
      defaultsTo: '127.0.0.1'
    },
    //
    port: {
      description: 'The port on which the Redis server is running.',
      example: '6379',
      defaultsTo: '6379'
    },
    //
    pass: {
      description: 'The password (if any) for the Redis server.',
      example: 'iheartredis'
    },
    //
    db: {
      description: 'The index of the database to connect to.',
      example: 123
    }
    //
  },
  //
  //
  exits: {
    //
    success: {
      outputFriendlyName: 'Redis URL',
      outputDescription: 'A fully-qualified URL for connecting to a Redis server.',
      outputExample: 'redis://:secret@127.0.0.1:6379/12'
    },
    //
  },
  //
  //
  fn: function (inputs, exits){

    // Every Redis URL starts with 'redis://'.
    var url = 'redis://';

    // Add the optional password.
    if (inputs.pass) {
      url += ':' + inputs.pass + '@';
    }

    // Add the host.
    url += inputs.host;

    // Add the port.
    url += ':' + inputs.port;

    // Add the optional database.
    if (inputs.db) {
      url += '/' + inputs.db;
    }

    // Return the finished URL through the "success" exit.
    return exits.success(url);

  }


};