Skip to content

Basic Rerouter is a minimal and lightning-fast server selector that pings your predefined servers and returns the one with the lowest response time. It's ideal for routing requests to the fastest available server dynamically.

License

Notifications You must be signed in to change notification settings

Houloude9IOfficial/basic_rerouter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌐 Basic Rerouter

Basic Rerouter is a minimal and lightning-fast server selector that pings your predefined servers and returns the one with the lowest response time. It's ideal for routing requests to the fastest available server dynamically.


✨ Features

  • Ping-Based Selection – Measures live latency to each server and selects the fastest.

  • 🔧 Custom Server List – Easily define multiple servers with custom settings.

  • 📊 Flexible Output – Return the best server, all pings, or full metadata.

  • 🧘 Lightweight & Fast – Built for speed with minimal overhead and no bloat.


📦 Installation

git  clone  https://github.com/Houloude9IOfficial/basic_rerouter.git

cd  basic_rerouter

npm  install

🚀 Usage

Start the server with:

npm  start

OR

npm  run  start

⚙️ Configuration

Edit your server list in config.js:

let servers = [
  {
    name: "Server 1",

    url: "https://myserver.onrender.com",

    method: "GET",

    ping_endpoint: "/ping",

    active: true,

    show: true,
  },

  {
    name: "Server 2",

    url: "https://myserver_1234.dev",

    method: "GET",

    ping_endpoint: "/ping",

    active: false,

    show: true,
  },

  {
    name: "Server 3 (Automatically Offline)",

    url: "https://myserver_1234.mydomain.com",

    method: "GET",

    ping_endpoint: "/ping",

    active: false,

    show: true,
  },

  {
    name: "Server 4 (Hidden)",

    url: "https://myserver_abc.mydomain.com",

    method: "GET",

    ping_endpoint: "/ping",

    active: false,

    show: false,
  },
];
  • active: If false, the server is automatically considered offline.

  • show: If false, the server is excluded from output.


🌐 How It Works

  1. A request is made to /server

  2. All active servers are pinged using the specified ping_endpoint

  3. Response times are measured

  4. Based on query parameters:

  • ✅ The fastest server is returned (default)

  • 📋 A list of all response times is returned (?advanced=all)

  • 📋 A full list including online status, metadata, etc. is returned (?advanced=full)


🔍 Query Parameters

Endpoint

/server

Options

| Parameter | Description |

|------------------|--------------------------------------------------|

| (none) | Returns the fastest server only (default) |

| ?advanced=all | Returns all servers with their ping times |

| ?advanced=full | Returns full metadata including status, ping |

Examples

Default (fastest server only)

GET /server
{
  "name": "PickRate - Frankfurt",

  "url": "https://pickrate.onrender.com",

  "status": "Online",

  "responseTime": 77
}

Advanced: All pings

GET /server?advanced=all
[
  {
    "name": "PickRate - Frankfurt",

    "url": "https://pickrate.onrender.com",

    "responseTime": 77
  },

  {
    "name": "PickRate - Oregon",

    "url": "https://pickrate-oregon.onrender.com",

    "responseTime": 236
  }
]

Advanced: Full metadata

GET /server?advanced=full
[
  {
    "name": "PickRate - Frankfurt",

    "url": "https://pickrate.onrender.com",

    "status": "Online",

    "responseTime": 77
  },

  {
    "name": "PickRate - Oregon",

    "url": "https://pickrate-oregon.onrender.com",

    "status": "Online",

    "responseTime": 236
  }
]

📃 Other Endpoints:

/ping

Returns "pong" with or without a random phrase (configured in config.js)


🛠️ Use Cases

  • 🌍 Dynamic region-based routing

  • 🎮 Multiplayer game server selection

  • 🧪 Backend testing and latency benchmarking

  • ⚙️ Smart endpoint selector for API or edge apps


🔗 Services using Basic Rerouter


💡 Why Use Basic Rerouter?

Stop guessing which server is fastest. Basic Rerouter automatically detects and returns the best option based on real-time latency, allowing your apps to respond faster and smarter — with no extra setup or tools.


🧑‍💻 Author

Made with care by Houloude9 – because performance should be simple.


📜 License

MIT – Free to use, modify, improve, or break. Just don’t blame me if your internet isn't fast 😉

About

Basic Rerouter is a minimal and lightning-fast server selector that pings your predefined servers and returns the one with the lowest response time. It's ideal for routing requests to the fastest available server dynamically.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors