444d2ca7dd
* Revert "Revert "feat(structured logging): implements structured logging for backend (#1217)" (#1227)"
This reverts commit 63e6581162.
* Use pino-http instead of express pino logger
* Use correct reference to knex and do not instantiate HttpLogger prematurely
* Adds missing dependency for pino to webhook-service
* Do not instantiate middleware when passed to express
* Refactor to move logging into shared
* Copy shared packages into dockerfiles
* Build shared workspace in docker build-stage for fileimport & webhook
51 lines
1.1 KiB
TypeScript
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
|
|
}
|