chore: migrate to eslint 9
[poolifier.git] / examples / typescript / smtp-client-pool / src / worker.ts
CommitLineData
9aef1431 1import { createTransport } from 'nodemailer'
f8374594 2import type SMTPTransport from 'nodemailer/lib/smtp-transport/index.js'
ded253e2
JB
3import { ThreadWorker } from 'poolifier'
4
ef083f7b 5import type { WorkerData } from './types.js'
9aef1431 6
f8374594 7class SmtpClientWorker extends ThreadWorker<
3a502712
JB
8 WorkerData,
9 SMTPTransport.SentMessageInfo
f8374594 10> {
9aef1431
JB
11 public constructor () {
12 super({
13 nodemailer: async (workerData?: WorkerData) => {
f8374594 14 return await createTransport(workerData?.smtpTransport).sendMail(
3a502712 15 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
67f3f2d6 16 workerData!.mail
9aef1431 17 )
3a502712 18 },
9aef1431
JB
19 })
20 }
21}
22
23export const smtpClientWorker = new SmtpClientWorker()