Sign inSign up

jefriherditriyanto/rest-api-logger

By jefriherditriyanto

Updated 7 months ago

Image
Networking
API management
Monitoring & observability
0

665

jefriherditriyanto/rest-api-logger repository overview

rest-api-logger

A lightweight REST API playground + real-time request logger built with Bun.

It exposes a JSON API endpoint and a professional web dashboard that streams request logs via WebSocket (auto reconnect) and persists them in localStorage.

Features

  • Real-time request logging via WebSocket (/ws)
  • Web dashboard served when Accept: text/html (responsive UI)
  • Persist logs to localStorage (survives refresh)
  • Delete individual logs or clear all
  • Echo response: returns method, path, query, headers, and parsed JSON body

Quick start (Docker)

Pull the image:

docker pull jefriherditriyanto/rest-api-logger:latest

Run it:

docker run --rm -p 3000:3000 jefriherditriyanto/rest-api-logger:latest

Open the dashboard:

  • http://localhost:3000/

Usage

Dashboard (HTML)

The dashboard is returned when the client sends Accept: text/html.

Examples:

curl -H "Accept: text/html" http://localhost:3000/
API (JSON)

Any request that does not ask for text/html will:

  • Be logged to the server console
  • Be pushed to the WebSocket clients
  • Return a JSON response

Example:

curl -X POST http://localhost:3000/api/test \
  -H "Content-Type: application/json" \
  -d '{"hello":"world"}'

Response includes:

  • method
  • path
  • query
  • headers
  • body
WebSocket endpoint
  • ws://<host>/ws

Each log event contains (at minimum):

  • id
  • timestamp
  • method
  • origin
  • path
  • fullUrl
  • query
  • headers
  • body

Local development

Install dependencies:

bun install

Run:

bun run index.ts

The server listens on:

  • http://localhost:3000/

Source code

Contributors

Thanks to everyone who contributes to this project.

If you want to contribute, feel free to open an issue or submit a pull request.

Donation

If this project helps you, consider supporting its development.

  • GitHub Sponsors: (add your link)
  • Ko-fi: (add your link)
  • Trakteer: (add your link)

Tag summary

Content type

Image

Digest

sha256:40896cc95

Size

65.4 MB

Last updated

7 months ago

docker pull jefriherditriyanto/rest-api-logger