Files
speckle-server/packages/server/modules/emails/index.ts
T
Iain Sproat 4d01e13a84 feat(structured logging) (#1242)
* Revert "Revert structured logging 2 (#1240)"
This reverts commit 78ecaeffcb.
* Logging should not be bundled into core shared directory
* making sure observability stuff isnt bundled into frontend


Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
2022-12-06 11:51:18 +00:00

51 lines
1.1 KiB
TypeScript

/* istanbul ignore file */
import { moduleLogger } from '@/logging/logging'
import * as SendingService from '@/modules/emails/services/sending'
import { initializeVerificationOnRegistration } from '@/modules/emails/services/verification/request'
import { initializeTransporter } from '@/modules/emails/utils/transporter'
import { Optional, SpeckleModule } from '@/modules/shared/helpers/typeHelper'
let quitVerificationListeners: Optional<() => void> = undefined
const emailsModule: SpeckleModule = {
init: async (app, isInitial) => {
moduleLogger.info('📧 Init emails module')
// init transporter
await initializeTransporter()
// init rest api
;(await import('./rest')).default(app)
// init event listeners
if (isInitial) {
quitVerificationListeners = initializeVerificationOnRegistration()
}
},
shutdown() {
quitVerificationListeners?.()
}
}
async function sendEmail({
from,
to,
subject,
text,
html
}: {
from?: string
to: string
subject: string
text: string
html: string
}) {
return SendingService.sendEmail({ from, to, subject, text, html })
}
export = {
...emailsModule,
sendEmail
}