Deep DivesNotification

Development

Local development guide for the RawStack Notification component.

Setup

cd services/notification
npm install
cp .env.example .env

Fill in your Resend and Twilio credentials. Use OVERRIDE_RECIPIENT_EMAIL to redirect all outbound emails to your own address during development.

Build

npm run build    # Compile TypeScript → dist/
npm run watch    # Watch mode

The compiled Lambda handler is output to dist/index.js.

Adding a new notification

  1. Create a strategy in src/strategy/notifications/:
// src/strategy/notifications/MyEvent.ts
import { NotificationStrategy } from '../NotificationStrategy';
import { EmailChannel } from '../../channel/EmailChannel';

export class MyEventNotification implements NotificationStrategy {
  channels = [new EmailChannel()];

  buildContent(event: MyEvent) {
    return {
      email: {
        to: event.recipientEmail,
        subject: 'Subject here',
        template: <MyEmailTemplate {...event} />,
      },
    };
  }
}
  1. Register it in src/strategy/NotificationRegistry.ts:
registry.set('MyEvent', new MyEventNotification());
  1. Create an email template in src/content/ using React Email components.

Testing notifications locally

The Lambda handler can be invoked directly by calling handler(event) with a mock EventBridge event payload. See existing tests for examples.