Skip to content

Commit

Permalink
fix(mail): fix fake driver
Browse files Browse the repository at this point in the history
Fix fake driver arguments
  • Loading branch information
Frantz Kati committed Jan 16, 2021
1 parent d2d462d commit 369852a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
4 changes: 4 additions & 0 deletions packages/cms/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
@tailwind components;
@tailwind utilities;

.base-body {
@apply antialiased font-sans text-tensei-gray-900;
}

.tensei {
@apply text-white py-2 px-4 font-bold rounded-lg shadow-lg;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cms/plugin/template/index.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link media="all" href="/{{name}}" rel="stylesheet" />
{{/styles}}
</head>
<body class='antialiased font-sans text-tensei-gray-900'>
<body class='base-body'>
<div id="app"></div>
<div id='modal-root'></div>
<div id='dropdown-root'></div>
Expand Down
5 changes: 4 additions & 1 deletion packages/mail/src/MailManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
QueueMonitorCallback,
MailManagerContract,
MessageComposeCallback,
MessageNode,
} from '@tensei/mail'

import { Mailer } from './Mailer'
Expand Down Expand Up @@ -222,7 +223,9 @@ export class MailManager

protected createFake(_: string, config: any) {
const { FakeDriver } = require('./drivers/Fake')
return new FakeDriver(config, this.logger)
return new FakeDriver((message: MessageNode) => {
this.logger.info(JSON.stringify(message, null, 2))
}, this.logger)
}

/**
Expand Down
8 changes: 3 additions & 5 deletions packages/mail/src/drivers/Fake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
export class FakeDriver implements FakeDriverContract {
private transporter: any

constructor(private listener: TrapCallback, private logger: Config['logger']) {
constructor(private listener: TrapCallback) {
this.transporter = nodemailer.createTransport({
jsonTransport: true,
})
Expand All @@ -38,11 +38,9 @@ export class FakeDriver implements FakeDriverContract {
throw new Error('Driver transport has been closed and cannot be used for sending emails')
}

const listenerResponse = this.listener(message)
const response = await this.transporter.sendMail(message)

this.logger.info(JSON.stringify(message, null, 3))

return { ...response }
return { ...response, ...listenerResponse }
}

/**
Expand Down

0 comments on commit 369852a

Please sign in to comment.