Skip to content

marcuwynu23/nodejs-webhooks-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js Webhooks Sample

This repository demonstrate a simple webhook sender and receiver implementation using Node.js, Express, and TypeScript.

Overview

  • Receiver – An Express server that listens for incoming webhook POST requests at /webhook, verifies the HMAC-SHA256 signature, and processes events.
  • Sender – A script that sends sample webhook events (user.created, order.paid, etc.) to the receiver with a signed payload.

Getting Started

# Install dependencies
npm install

# Build TypeScript
npm run build

# Start the receiver
npm start

# In another terminal, run the sender demo
npm run sender

Development

# Run receiver with ts-node (no build step)
npm run receiver

# Run tests
npm test

Project Structure

src/
  app.ts        – Express app and webhook route
  receiver.ts   – Server entry point
  sender.ts     – Webhook sender demo
tests/
  receiver.test.ts – Integration tests for the receiver

Security

Webhook payloads are signed using HMAC-SHA256. The receiver verifies the signature before processing any event. Always use a strong, secret key stored in environment variables (not hardcoded) in production.

About

This repository demonstrate a simple webhook sender and receiver implementation using Node.js, Express, and TypeScript.

Topics

Resources

Stars

Watchers

Forks

Contributors