lib/routes/apiv1.js
function postExec (req, res) {
  let cmd = req.body.cmd;
  let connection = res.locals.connection;
  let parts = myutil.split(cmd);
  parts[0] = parts[0].toLowerCase();
  let commandName = parts[0].toLowerCase();

  // must be in our white list to be allowed in read only mode
  if (req.app.locals.redisReadOnly) {
    if (!isReadOnlyCommand(commandName, connection)) {
      return res.send('ERROR: Command not read-only');
    }
  }

  let args = parts.slice(1);
  args.push(function (err, results) {
      if (err) {
          return res.send(err.message);
      }
      return res.send(JSON.stringify(results));
  });
  // check if command is valid is done by ioredis if called with
  // 'connection.call(command, ...)' and our callback called to handle it
  // but throws Error if called via 'connection[commandName].apply(connection, ...)'
  connection.call(commandName, ...args);
}
function postExec (req, res) {
  let cmd = req.body.cmd;
  let connection = res.locals.connection;
  let parts = myutil.split(cmd);
  parts[0] = parts[0].toLowerCase();
  let commandName = parts[0].toLowerCase();

  // must be in our white list to be allowed in read only mode
  if (req.app.locals.redisReadOnly) {
    if (!isReadOnlyCommand(commandName, connection)) {
      return res.send('ERROR: Command not read-only');
    }
  }

  let args = parts.slice(1);
  args.push(function (err, results) {
      if (err) {
          return res.send(err.message);
      }
      return res.send(JSON.stringify(results));
  });
  // check if command is valid is done by ioredis if called with
  // 'connection.call(command, ...)' and our callback called to handle it
  // but throws Error if called via 'connection[commandName].apply(connection, ...)'
  connection.call(commandName, ...args);
}
function postExec ( req , res ) { let cmd = req . body . cmd ; let connection = res . locals . connection ; let parts = myutil . split ( cmd ) ; parts [ 0 ] = parts [ 0 ] . toLowerCase ( ) ; let commandName = parts [ 0 ] . toLowerCase ( ) ; // must be in our white list to be allowed in read only mode if ( req . app . locals . redisReadOnly ) { if ( ! isReadOnlyCommand ( commandName , connection ) ) { return res . send ( 'ERROR: Command not read-only' ) ; } } let args = parts . slice ( 1 ) ; args . push ( function ( err , results ) { if ( err ) { return res . send ( err . message ) ; } return res . send ( JSON . stringify ( results ) ) ; } ) ; // check if command is valid is done by ioredis if called with // 'connection.call(command, ...)' and our callback called to handle it // but throws Error if called via 'connection[commandName].apply(connection, ...)' connection . call ( commandName , ... args ) ; }
this needs special handling for read-only mode. Must check all commands and classify if command to view or manipulatie data...
this needs special handling for read - only mode . Must check all commands and classify if command to view or manipulatie data ...