All files / src/services sms.service.ts

24% Statements 6/25
27.27% Branches 3/11
0% Functions 0/9
30% Lines 6/20

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  7x                 7x 7x 7x 7x 7x                
import { SNSClient, PublishCommand } from '@aws-sdk/client-sns';
import { config } from 'dotenv';

config();

export async function sendSMS({ phoneNumber, message }: { phoneNumber: string; message: string }) {
  const client = new SNSClient({ region: process.env.AWS_REGION });

  const params = {
    Message: message,
    PhoneNumber: phoneNumber,
  };
 
  const command = new PublishCommand(params);
 
  try {
    const data = await client.send(command);
    console.log('Success', data);
  } catch (err) {
    console.error('Error', err);
  }
}