Skip to content

A simple Express.js server with LocalTunnel integration to test webhook callbacks from third-party APIs like payment gateways, messaging platforms, and more.

License

Notifications You must be signed in to change notification settings

MatyilaSango/webhook-test-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📦 webhook-test-server

A simple Express.js server with LocalTunnel integration to test webhook callbacks from third-party APIs like payment gateways, messaging platforms, and more.


✨ Features

  • 🌐 Exposes a local server to the internet using LocalTunnel
  • 📬 Logs incoming webhook requests for easy inspection
  • 📄 Displays headers, body, and query parameters
  • 🛠️ Easily customizable for testing different webhook payloads
  • 🔁 Supports all HTTP methods (GET, POST, PUT, DELETE, etc.)

🚀 Getting Started

⚙️ Requirements

To run this project, make sure you have the following installed:

Requirement Version Description
Node.js >= 14.x JavaScript runtime to run the server
npm >= 6.x Node package manager (comes with Node.js)
Internet Access Required Needed to establish a public tunnel via LocalTunnel

📦 Installation

npm i webhook-test-server

⚙️ Server API

server(options, callback)

Initializes and starts the Express server, and lets you define your own routes via the callback function.


📌 Parameters

Name Type Description
options ServerOptions Configuration options for starting the server (see below).
callback (app: Omit<Express, "listen">) => void A function that receives the Express app instance (without .listen) so you can define routes using app.get, app.post, etc.

🛠️ ServerOptions

Option Type Required Description
port number ✅ Yes The local port number on which to run the server. Example: 3000

✅ Example Usage

import { server } from "webhook-test-server";

server({ port: 3000 }, (app) => {
  // Define your endpoints
  app.post("/webhook", (req, res) => {
    console.log("📬 Webhook received:", {
      method: req.method,
      headers: req.headers,
      query: req.query,
      body: req.body,
    });

    res.status(200).json({ received: true });
  });
});

🌐 Public URL via LocalTunnel

When the server starts, it automatically uses LocalTunnel to expose your local Express server to the internet.
Once running, it logs a public URL like:

   ╭───────────────────────────────────────╮
   │                                       │
   │       🚀 Server is running on:        │
   │   https://public-ties-test.loca.lt    │
   │                                       │
   ╰───────────────────────────────────────╯

📄 License

This project is licensed under the MIT License.

About

A simple Express.js server with LocalTunnel integration to test webhook callbacks from third-party APIs like payment gateways, messaging platforms, and more.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published