Skip to content

A TypeScript-based notification handler built with AWS SAM. Handles email and SMS notifications using a Lambda function.

Notifications You must be signed in to change notification settings

mvelezg99/notification-aws-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Notification Handler Service

A TypeScript-based notification handler built with AWS SAM that processes email and SMS notifications using AWS Lambda, Amazon SES, and Amazon SNS.


πŸ“š Table of Contents


πŸ“‹ Project Overview

This project demonstrates a notification system using AWS SAM and TypeScript. The system processes two types of notifications:

1. Email Notifications: Sent using Amazon Simple Email Service (SES). 2. SMS Notifications: Sent using Amazon Simple Notification Service (SNS).


πŸ“ Folder Structure

  source/
  β”œβ”€β”€ package.json            # Dependencies and scripts
  β”œβ”€β”€ template.yaml           # SAM template for AWS resources
  β”œβ”€β”€ tsconfig.json           # TypeScript configuration
  β”œβ”€β”€ handler.ts              # Lambda entry point
  β”œβ”€β”€ notification/
  β”‚   β”œβ”€β”€ email.ts            # Email notification logic
  β”‚   β”œβ”€β”€ sms.ts              # SMS notification logic
  β”‚   β”œβ”€β”€ processor.ts        # Notification processing logic
  β”‚   β”œβ”€β”€ types/              # TypeScript interfaces and types
  β”‚   β”‚   └── index.ts
  β”‚   β”œβ”€β”€ utils/              # Utility functions
  β”‚       └── index.ts
  β”œβ”€β”€ tests/                  # Unit tests
  β”‚   └── ...                 # Test files
  β”œβ”€β”€ dist/                   # Compiled output
  β”œβ”€β”€ .aws-sam/               # SAM build artifacts
  β”œβ”€β”€ events/                 # Sample event payloads
  └── node_modules/           # Dependencies

πŸ› οΈ Prerequisites

  • Node.js (version 18 or higher)
  • AWS CLI installed and configured with your credentials
  • AWS SAM CLI installed
  • Docker installed and running (required for local testing with SAM)
  • TypeScript installed globally
  • Amazon SES setup:
    • A verified email in Amazon SES (sandbox or production mode).
  • Amazon SNS setup:
    • Ensure permissions to publish messages to an SNS topic.

πŸ”‘ Configuration Notes

  • AWS CLI Configuration:
    • Ensure that your AWS CLI is configured with the necessary permissions.
      aws configure
  • Email Configuration:
    • Update senderEmail in notification/email.ts with your verified SES email.
  • SNS Permissions:
    • Ensure that the Lambda role allows SNS:Publish to your desired topic.

πŸš€ Quick Start

1. Clone the repository

git clone https://github.com/mvelezg99/notification-aws-handler.git
cd source

2. Install dependencies

npm install

3. Build the project πŸ”¨

npm run build

4. Build the SAM application πŸ’»

npm run sam:build

5. Start the local SAM application πŸš€

npm run sam:start

6. Test the lambda function πŸ€“ Use a tool like Postman or cURL to test the Lambda function locally.

  • Endpoint: http://127.0.0.1:3000/notifications
  • Method: POST
  • Body Example:
// For Email
{
  "type": "email",
  "id": "1",
  "timestamp": "2024-12-01T12:00:00Z",
  "recipient": "recipient@example.com",
  "subject": "Hello",
  "body": "This is a test email."
}
// For SMS
{
  "type": "sms",
  "id": "2",
  "timestamp": "2024-12-01T12:00:00Z",
  "phoneNumber": "+1234567890",
  "message": "This is a test SMS."
}

πŸ§ͺ Running Tests

Run the unit tests using the following command:

npm run test

About

A TypeScript-based notification handler built with AWS SAM. Handles email and SMS notifications using a Lambda function.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published