@@ -91,6 +91,9 @@ const {
9191 createJWTAuth ,
9292 createLogger ,
9393 createRateLimit ,
94+ createPrometheusMiddleware ,
95+ createMetricsHandler ,
96+ createPrometheusIntegration ,
9497} = require (' 0http-bun/lib/middleware' )
9598```
9699
@@ -104,6 +107,9 @@ import {
104107 createJWTAuth ,
105108 createLogger ,
106109 createRateLimit ,
110+ createPrometheusMiddleware ,
111+ createMetricsHandler ,
112+ createPrometheusIntegration ,
107113} from ' 0http-bun/lib/middleware'
108114
109115// Import types
@@ -545,7 +551,11 @@ Comprehensive Prometheus metrics integration for monitoring and observability wi
545551> 📦 **Required dependency**: ` bun install prom- client`
546552
547553` ` ` javascript
548- import {createPrometheusIntegration } from ' 0http-bun/lib/middleware/prometheus'
554+ const {
555+ createPrometheusMiddleware ,
556+ createMetricsHandler ,
557+ createPrometheusIntegration ,
558+ } = require (' 0http-bun/lib/middleware' )
549559
550560// Simple setup with default metrics
551561const prometheus = createPrometheusIntegration ()
@@ -568,6 +578,12 @@ The Prometheus middleware automatically collects:
568578#### Advanced Configuration
569579
570580` ` ` javascript
581+ const {
582+ createPrometheusMiddleware ,
583+ createMetricsHandler ,
584+ createPrometheusIntegration ,
585+ } = require (' 0http-bun/lib/middleware' )
586+
571587const prometheus = createPrometheusIntegration ({
572588 // Control default Node.js metrics collection
573589 collectDefaultMetrics: true ,
@@ -602,6 +618,12 @@ const prometheus = createPrometheusIntegration({
602618#### Custom Business Metrics
603619
604620` ` ` javascript
621+ const {
622+ createPrometheusIntegration ,
623+ } = require (' 0http-bun/lib/middleware' )
624+
625+ // Get the prometheus client from the integration
626+ const prometheus = createPrometheusIntegration ()
605627const {promClient } = prometheus
606628
607629// Create custom metrics
@@ -644,6 +666,8 @@ router.post('/orders', async (req) => {
644666#### Metrics Endpoint Options
645667
646668` ` ` javascript
669+ const {createMetricsHandler } = require (' 0http-bun/lib/middleware' )
670+
647671// Custom metrics endpoint
648672const metricsHandler = createMetricsHandler ({
649673 endpoint: ' /custom-metrics' , // Default: '/metrics'
@@ -1029,8 +1053,8 @@ Apply middleware only to specific paths:
10291053
10301054` ` ` typescript
10311055// API-only middleware
1032- router .use (' /api/*' , jwtAuth ({secret: ' api-secret' }))
1033- router .use (' /api/*' , rateLimit ({max: 1000 }))
1056+ router .use (' /api/*' , createJWTAuth ({secret: ' api-secret' }))
1057+ router .use (' /api/*' , createRateLimit ({max: 1000 }))
10341058
10351059// Admin-only middleware
10361060router .use (' /admin/*' , adminAuthMiddleware)
0 commit comments