Skip to content

ls-4/RequestBin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RequestBin

RequestBin Database Setup

A simple TypeScript database service for your RequestBin clone using PostgreSQL + MongoDB.

Setup

  1. cd into backend directory.
cd backend
  1. Install dependencies:
npm install
  1. Set up environment variables (copy .env.example to .env and fill in your values):
cp .env.example .env
  1. Make sure PostgreSQL and MongoDB are running.

4.1. Create the PostgreSQL database (MongoDB creates its database automatically):

createdb requestbin
# If you get a permission error, try: createdb -U <your_username> requestbin

Note: If your PostgreSQL user isn't postgres, update PG_USER in your .env file. On macOS with Homebrew, it's usually your system username.

  1. Run the test script to verify everything works:
npm run dbtest
  1. Start the backend dev server
npm run dev

Backend API Endpoints

POST /bins/:binRoute

  • Create bin

Request body

{
  "bin_route": "abc123",
}

Response: 201

{
  "bin_route": "abc123",
  "token": "sk_92fj3k1"
}

Note

  • The token is generated by the server and returned in the response.
  • Save both bin_route and token as they are needed to view the bin.

Unsuccessful responses

  • 400 {"error":"Invalid JSON: "bin_route" is required."}
  • 400 {"error":"Invalid JSON: "bin_route" must be a string."}
  • 409 {"error":"Bin with route <binRoute> already exists."}

ALL /in/:binRoute

  • Collect webhook request in bin (accepts any method).
    • Replace :binRoute with bin_route returned from POST /bins.

Response: 204

  • No content

Unsuccessful responses

  • 404 {"error":"Bin with route <binRoute> not found."}

GET /bins/:binRoute

  • Retrieve list of requests in bin
    • Requires header: Authorization: Bearer <token>

Response: 200

{
  "bin_route": "abc123",
  "requests": [
    {
      "method": "POST",
      "created_at": "2026-03-07 19:12:45",
      "path": "/in/abc123",
      "headers": { "content-type": "application/json" },
      "params": { "category": "webhooks" },
      "body": { "example": true }
    }
  ]
}

Note

  • If a request's body cannot be returned as JSON, it will be returned as a string instead.

Unsuccessful responses

  • 401 {"error":"Unauthorized: No token provided"}
  • 401 {"error":"Unauthorized: Token invalid"}
  • 404 {"error":"Bin with route <binRoute> not found."}

DELETE /bins/:binRoute

  • Delete a bin and all requests
    • Requires header: Authorization: Bearer <token>

Response: 204

  • No content

Unsuccessful responses

  • 401 {"error":"Unauthorized: No token provided"}
  • 401 {"error":"Unauthorized: Token invalid"}
  • 404 {"error":"Bin with route <binRoute> not found."}

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors