All files / src/context defaults.ts

100% Statements 11/11
100% Branches 12/12
100% Functions 1/1
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 381x   11x   11x     11x   11x 4x           11x 6x                 11x 1x               11x    
export function emailProviderDefaults(emailProvider) {
  // eslint-disable-line
  const updated = { ...emailProvider };
 
  const apiKeyProviders = ['mailgun', 'mandrill', 'sendgrid', 'sparkpost'];
 
  // Add placeholder for credentials as they cannot be exported
  const { name } = updated;
 
  if (apiKeyProviders.includes(name)) {
    updated.credentials = {
      api_key: `##${name.toUpperCase()}_API_KEY##`,
      ...(updated.credentials || {}),
    };
  }
 
  if (name === 'smtp') {
    updated.credentials = {
      smtp_host: '##SMTP_HOSTNAME##',
      smtp_port: '##SMTP_PORT##',
      smtp_user: '##SMTP_USER##',
      smtp_pass: '##SMTP_PASS##',
      ...(updated.credentials || {}),
    };
  }
 
  if (name === 'ses') {
    updated.credentials = {
      accessKeyId: '##SES_ACCESS_KEY_ID##',
      secretAccessKey: '##SES_ACCESS_SECRET_KEY##',
      region: '##SES_AWS_REGION##',
      ...(updated.credentials || {}),
    };
  }
 
  return updated;
}