const URL = 'http://localhost:3000/api/';

const randomLowerCase = function() {
  let possible = 'abcdefghijklmnopqrstuvwxyz';
  return (possible.charAt(Math.floor(Math.random() * possible.length)));
};

const randomUpperCase = function() {
  let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  return (possible.charAt(Math.floor(Math.random() * possible.length)));
};

const randomNumber = function(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return (Math.floor(Math.random() * (max - min + 1)) + min);
};

const randomWord = function(num, allUpper = false, firstUpper = false) {
  let word = '';
  for (let i = 0; i < num; i++) {
    if (!allUpper) {
      if (i == 0 && firstUpper) {
        word = word + randomUpperCase();
      } else {
        word = word + randomLowerCase();
      }
    } else {
      word = word + randomUpperCase();
    }
  }
  return word;
};

const randomId = function(num) {
  let word = '';
  for (let i = 0; i < num; i++) {
    if (randomNumber(0, 1) == 0) {
      word = word + randomNumber(0, 9);
    } else {
      word = word + randomLowerCase();
    }
  }
  return word;
};

module.exports = {
  URL,
  randomLowerCase,
  randomUpperCase,
  randomNumber,
  randomWord,
  randomId,
};