Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 2x 2x 2x 2x 1x 1x | import { Injectable, Logger } from '@nestjs/common';
export interface Notification {
recipient: string;
subject: string;
body: string;
}
/**
* Abstraction over the delivery channel (email, SMS, push...). The consumer
* depends on this token, so swapping the channel — or recording calls in
* tests — never touches message-handling code.
*/
export abstract class NotificationSender {
abstract send(notification: Notification): Promise<void>;
}
/** Stand-in channel until a real provider is integrated. */
@Injectable()
export class LoggingNotificationSender extends NotificationSender {
private readonly logger = new Logger(LoggingNotificationSender.name);
send(notification: Notification): Promise<void> {
this.logger.log(
`to=${notification.recipient} subject="${notification.subject}"`,
);
return Promise.resolve();
}
}
|