1.0.5 ā€¢ Published 12 months ago

@nestjs-1729/digit-sender v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

digit-sender

šŸ‘‰ A PIN sender package for NestJS.

šŸš€ Install

npm i @nestjs-1729/digit-sender

šŸ–µ Preview

šŸ’» Usage

/** .../app.module.ts */

...
import { DigitSenderModule } from '@nestjs-1729/digit-sender/dist/digit-sender.module';
...

@Module({
  ...
  imports: [
    ...
    DigitSenderModule.forRoot({
      hostType: "gmail",
      auth: {
        user: process.env.MAIL_USER,
        pass: process.env.MAIL_PASSWD
      }
    })
    ...
  ]
  ...
})
/** .../app.service.ts */

...
import {DigitSenderService} from '@nestjs-1729/digit-sender/dist/digit-sender.service'
...

@Injectable()
export class AppService {
  ...
  constructor(
    private digitSenderService: DigitSenderService
  ){}
  
  async sendPinViaEmail(...){
    await this.digitSenderService.sendPin({
      to: 'to@sample.com',
      from: 'from@sample.com',
      contactMail: 'contact@sample.com',
      subject: 'Sample Subject',
      pinSize: 6,
      wordmark: 'Sample'
    },
    (pin: string) => {
      /** pin handler */
    },
    (result: any) => {
      /** success handler */
    },
    (error: any) => {
      /** error handler */
    })
  }
  ...
}

šŸ“– Document

DigitSenderModule.forRoot({...})

DigitSenderModule.forRoot({
  hostType: string,
  auth: {
    user: string,
    pass: string
  },
  hostInfo: {
    host: string,
    port: number,
    secure: boolean
  }
}) 

hostType - gmail | custom hostInfo - Optional | Mandatory

sendPin(...)

this.digitSenderService.sendPin(sendMail, pinHandler, [successHandler, errorHandler])
sendMail = {
    to: string, 
    from: string,
    contactMail: string,
    subject: string, 
    pinSize: number,
    wordmark: string,
}

pinHandler - A function that can manage with generated pin before sending mail. successHandler - A function that can execute after successful email sending process. errorHandler - A function that can execute after unsuccessful email sending process.

pin.hbs

You can find and edit pin.hbs file at .../dist/templates folder. Furthermore, you can see the bunch of commented html code with <!-- optional -->. You can use it whenever you want to add the Ā© Copyright on the bottom of the email content.

šŸ§‘ā€šŸ’» Contributor

Email Template Designed By JAE