1- # 🚀 BunGate
1+ # 🚀 Bungate
22
33> ** The Lightning-Fast HTTP Gateway & Load Balancer for the Modern Web**
44
77[ ![ Performance] ( https://img.shields.io/badge/Performance-Blazing%20Fast-orange )] ( https://github.com/BackendStack21/bungate )
88[ ![ License] ( https://img.shields.io/badge/License-MIT-green )] ( ./LICENSE )
99
10- ** BunGate ** is a next-generation HTTP gateway and load balancer that harnesses the incredible speed of Bun.js to deliver unparalleled performance for modern web applications. Built from the ground up with TypeScript, it provides enterprise-grade features with zero-config simplicity.
10+ ** Bungate ** is a next-generation HTTP gateway and load balancer that harnesses the incredible speed of Bun to deliver unparalleled performance for modern web applications. Built from the ground up with TypeScript, it provides enterprise-grade features with zero-config simplicity.
1111
12- ## ⚡ Why BunGate ?
12+ ## ⚡ Why Bungate ?
1313
14- - ** 🔥 Blazing Fast** : Built on Bun.js - up to 4x faster than Node.js alternatives
14+ - ** 🔥 Blazing Fast** : Built on Bun - up to 4x faster than Node.js alternatives
1515- ** 🎯 Zero Config** : Works out of the box with sensible defaults
16- - ** 🧠 Smart Load Balancing** : 5 supported load balancing algorithms: ` round-robin ` , ` least-connections ` , ` random ` , ` weighted ` , ` ip-hash `
16+ - ** 🧠 Smart Load Balancing** : 5 load balancing algorithms: ` round-robin ` , ` least-connections ` , ` random ` , ` weighted ` , ` ip-hash `
1717- ** 🛡️ Production Ready** : Circuit breakers, health checks, and auto-failover
1818- ** 🔐 Built-in Authentication** : JWT, API keys, JWKS, and OAuth2 support out of the box
1919- ** 🎨 Developer Friendly** : Full TypeScript support with intuitive APIs
2020- ** 📊 Observable** : Built-in metrics, logging, and monitoring
2121- ** 🔧 Extensible** : Powerful middleware system for custom logic
2222
23- > See Benchmarks comparing BunGate with Nginx and Envoy in the [ benchmark directory] ( ./benchmark ) .
23+ > See benchmarks comparing Bungate with Nginx and Envoy in the [ benchmark directory] ( ./benchmark ) .
2424
2525## 🚀 Quick Start
2626
2727Get up and running in less than 60 seconds:
2828
2929``` bash
30- # Install BunGate
30+ # Install Bungate
3131bun add bungate
3232
3333# Create your gateway
@@ -47,16 +47,17 @@ const gateway = new BunGateway({
4747gateway .addRoute ({
4848 pattern: ' /api/*' ,
4949 loadBalancer: {
50+ strategy: ' least-connections' ,
5051 targets: [
51- ' http://api1.example.com' ,
52- ' http://api2.example.com' ,
53- ' http://api3.example.com' ,
52+ { url: ' http://api1.example.com' } ,
53+ { url: ' http://api2.example.com' } ,
54+ { url: ' http://api3.example.com' } ,
5455 ],
55- strategy: ' least-connections' ,
5656 healthCheck: {
5757 enabled: true ,
5858 interval: 30000 ,
5959 timeout: 5000 ,
60+ path: ' /health' ,
6061 },
6162 },
6263})
@@ -74,7 +75,7 @@ gateway.addRoute({
7475
7576// Start the gateway
7677await gateway .listen ()
77- console .log (' 🚀 BunGate running on http://localhost:3000' )
78+ console .log (' 🚀 Bungate running on http://localhost:3000' )
7879```
7980
8081** That's it!** Your high-performance gateway is now handling traffic with:
@@ -92,34 +93,36 @@ console.log('🚀 BunGate running on http://localhost:3000')
9293### 🚀 ** Performance & Scalability**
9394
9495- ** High Throughput** : Handle thousands of requests per second
95- - ** Low Latency** : Low latency routing with minimal overhead
96+ - ** Low Latency** : Minimal overhead routing with optimized request processing
9697- ** Memory Efficient** : Optimized for high-concurrent workloads
9798- ** Auto-scaling** : Dynamic target management and health monitoring
9899- ** Cluster Mode** : Multi-process clustering for maximum CPU utilization
99100
100101### 🎯 ** Load Balancing Strategies**
101102
102103- ** Round Robin** : Equal distribution across all targets
103- - ** Weighted Round Robin ** : Distribute based on server capacity
104- - ** Least Connections** : Route to least busy server
105- - ** IP Hash** : Consistent routing based on client IP
104+ - ** Weighted** : Distribute based on server capacity and weights
105+ - ** Least Connections** : Route to the least busy server
106+ - ** IP Hash** : Consistent routing based on client IP for session affinity
106107- ** Random** : Randomized distribution for even load
107- - ** Sticky Sessions** : Session affinity with cookie support
108+ - ** Sticky Sessions** : Session affinity with cookie-based persistence
108109
109110### 🛡️ ** Reliability & Resilience**
110111
111112- ** Circuit Breaker Pattern** : Automatic failure detection and recovery
112113- ** Health Checks** : Active monitoring with custom validation
113- - ** Timeout Management** : Route-level timeout controls
114+ - ** Timeout Management** : Route-level and global timeout controls
115+ - ** Auto-failover** : Automatic traffic rerouting on service failures
116+ - ** Graceful Degradation** : Fallback responses and cached data support
114117
115118### 🔧 ** Advanced Features**
116119
117120- ** Authentication & Authorization** : JWT, API keys, JWKS, OAuth2/OIDC support
118- - ** Middleware System** : Custom request/response processing
121+ - ** Middleware System** : Custom request/response processing pipeline
119122- ** Path Rewriting** : URL transformation and routing rules
120123- ** Rate Limiting** : Flexible rate limiting with custom key generation
121124- ** CORS Support** : Full cross-origin resource sharing configuration
122- - ** Request/Response Hooks** : Lifecycle event handling
125+ - ** Request/Response Hooks** : Comprehensive lifecycle event handling
123126
124127### 📊 ** Monitoring & Observability**
125128
@@ -131,11 +134,11 @@ console.log('🚀 BunGate running on http://localhost:3000')
131134
132135### 🎨 ** Developer Experience**
133136
134- - ** TypeScript First** : Full type safety and IntelliSense
135- - ** Zero Dependencies** : Minimal footprint with essential features
137+ - ** TypeScript First** : Full type safety and IntelliSense support
138+ - ** Zero Dependencies** : Minimal footprint with essential features only
136139- ** Hot Reload** : Development mode with automatic restarts
137- - ** Rich Examples ** : Comprehensive documentation and examples
138- - ** Testing Support** : Built-in testing utilities and mocks
140+ - ** Rich Documentation ** : Comprehensive examples and API documentation
141+ - ** Testing Support** : Built-in utilities for testing and development
139142
140143## 🏗️ Real-World Examples
141144
@@ -189,7 +192,7 @@ gateway.addRoute({
189192 hooks: {
190193 onError(req , error ): Promise <Response > {
191194 // Fallback to cached payment status
192- return getCachedPaymentStatus (req .params . id )
195+ return getCachedPaymentStatus (req .url )
193196 },
194197 },
195198})
@@ -246,11 +249,6 @@ Distribute traffic intelligently across multiple backends:
246249gateway .addRoute ({
247250 pattern: ' /products/*' ,
248251 loadBalancer: {
249- targets: [
250- ' http://api1.example.com' ,
251- ' http://api2.example.com' ,
252- ' http://api3.example.com' ,
253- ],
254252 strategy: ' weighted' ,
255253 targets: [
256254 { url: ' http://products-primary:3000' , weight: 70 },
@@ -271,16 +269,11 @@ gateway.addRoute({
271269gateway .addRoute ({
272270 pattern: ' /app/*' ,
273271 loadBalancer: {
274- targets: [
275- ' http://api1.example.com' ,
276- ' http://api2.example.com' ,
277- ' http://api3.example.com' ,
278- ],
279272 strategy: ' ip-hash' ,
280273 targets: [
281- ' http://app-server-1:3000' ,
282- ' http://app-server-2:3000' ,
283- ' http://app-server-3:3000' ,
274+ { url: ' http://app-server-1:3000' } ,
275+ { url: ' http://app-server-2:3000' } ,
276+ { url: ' http://app-server-3:3000' } ,
284277 ],
285278 stickySession: {
286279 enabled: true ,
@@ -354,7 +347,7 @@ gateway.addRoute({
354347
355348## 🔐 ** Built-in Authentication**
356349
357- BunGate provides comprehensive authentication support out of the box:
350+ Bungate provides comprehensive authentication support out of the box:
358351
359352#### JWT Authentication
360353
@@ -536,24 +529,9 @@ touch gateway.ts
536529import { BunGateway , BunGateLogger } from ' bungate'
537530
538531const logger = new BunGateLogger ({
539- level: ' error' ,
540- transport: {
541- target: ' pino-pretty' ,
542- options: {
543- colorize: true ,
544- translateTime: ' SYS:standard' ,
545- ignore: ' pid,hostname' ,
546- },
547- },
548- serializers: {
549- req : (req ) => ({
550- method: req .method ,
551- url: req .url ,
552- }),
553- res : (res ) => ({
554- statusCode: res .status ,
555- }),
556- },
532+ level: ' info' ,
533+ format: ' pretty' ,
534+ enableRequestLogging: true ,
557535})
558536
559537const gateway = new BunGateway ({
@@ -585,18 +563,18 @@ gateway.addRoute({
585563 },
586564})
587565
588- // Add public routes with another layer of authentication
566+ // Add public routes with API key authentication
589567gateway .addRoute ({
590568 pattern: ' /api/public/*' ,
591569 target: ' http://public-service:3002' ,
592570 auth: {
593571 apiKeys: [' public-key-1' , ' public-key-2' ],
594- apiKeyHeader: ' x-public -key' ,
572+ apiKeyHeader: ' x-api -key' ,
595573 },
596574})
597575
598576await gateway .listen ()
599- console .log (' 🚀 BunGate running on http://localhost:3000' )
577+ console .log (' 🚀 Bungate running on http://localhost:3000' )
600578```
601579
602580## 📄 License
@@ -607,6 +585,8 @@ MIT Licensed - see [LICENSE](LICENSE) for details.
607585
608586<div align =" center " >
609587
610- ** Built with ❤️ for the JavaScript Community**
588+ ** Built with ❤️ by BackendStack21 for the JavaScript Community**
589+
590+ [ 🏠 Homepage] ( https://github.com/BackendStack21/bungate ) | [ 📚 Documentation] ( https://github.com/BackendStack21/bungate#readme ) | [ 🐛 Issues] ( https://github.com/BackendStack21/bungate/issues ) | [ 💬 Discussions] ( https://github.com/BackendStack21/bungate/discussions )
611591
612592</div >
0 commit comments