@tc-libs/sms
v3.9.0
Published
Gateway SMS basato su AWS SNS.
Readme
@tc-libs/sms
Gateway SMS basato su AWS SNS.
Il package espone SmsModule, enum SMS_TYPE, interfaccia ISmSService e l'implementazione SmSAwsSnsService.
Registrazione
SmsModule.register(
{
aws: {
credential: {
key: process.env.AWS_ACCESS_KEY_ID!,
secret: process.env.AWS_SECRET_ACCESS_KEY!,
},
s3: {
region: process.env.AWS_REGION!,
bucket: '',
baseUrl: '',
},
},
},
true,
);Nota: l'opzione si chiama s3, ma il servizio usa solo region per configurare SNS.
Invio SMS
const sent = await this.smsService.sendSmS(
'+391234567890',
'Codice OTP: 123456',
'MyApp',
SMS_TYPE.TRANSACTIONAL,
);Il metodo:
- verifica prima se il numero e opt-out su SNS
- invia il messaggio con
SenderID - restituisce
trueofalse
Export pubblici
import {
ISmSService,
SMS_TYPE,
SmSAwsSnsService,
SmsModule,
} from '@tc-libs/sms';Sviluppo
nx build sms
nx test sms