Stand in front of the port
We log every mail without touching the handler or the mailer. A class that implements the mailer and asks for it stands in front of it.
fronds/blog/services/AuditMailer.ts
1
import type { Logger } from '@fougere/core';2
import type Mailer from './Mailer.js';3
4
export default class AuditMailer implements Partial<Mailer> {c5
constructor(private inner: Mailer, private log: Logger) {}a6
7
async send(subject: string): Promise<void> {8
this.log.info('sending', subject);b9
10
return this.inner.send(subject);11
}12
}point at a lettered line, or tap it, to see what grows from it
0 line changed under handlers/
Around a capability, not inside it.
Try it
$ curl -X POST localhost:4100/api/blog/posts/$ID/publish INF [app:blog:AuditMailer] (blog:PostHandler.publish) sending Published: Hi mail: Published: Hi