bugstack-sdk 1.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,51 +1,48 @@
1
1
  # bugstack-sdk
2
2
 
3
- Error capture SDK for Next.js 14+ App Router API routes. Automatically captures errors with full context and reports them to the BugStack service for AI-powered fix generation.
3
+ Framework-agnostic error capture SDK for Node.js. Automatically captures errors with full context and reports them to BugStack for AI-powered fix generation.
4
4
 
5
- **Get your API key at:** https://dashboard.bugstack.ai
5
+ **Get your API key at:** [dashboard.bugstack.ai](https://dashboard.bugstack.ai)
6
6
 
7
7
  ## Features
8
8
 
9
- - **Zero-config wrapping** - Simply wrap your route handlers with `withErrorCapture`
10
- - **Full error context** - Captures stack traces, request body, headers, query params
11
- - **Automatic sanitization** - Sensitive data (passwords, tokens, etc.) is automatically redacted
12
- - **Non-blocking** - Error reporting happens asynchronously without slowing down responses
13
- - **TypeScript first** - Full type safety with comprehensive type definitions
14
- - **Production ready** - Configurable timeouts, error handling, and kill switches
9
+ - **Multiple frameworks** — First-class support for Next.js, Express, and generic Node.js
10
+ - **Full error context** — Captures stack traces, request body, headers, query params, route params
11
+ - **Automatic sanitization** — Sensitive data (passwords, tokens, API keys) is redacted automatically
12
+ - **Non-blocking** — Error reporting is async and never slows down your responses
13
+ - **Deduplication** — Same errors are batched within a configurable time window
14
+ - **Retry queue** — Failed reports are retried with exponential backoff
15
+ - **TypeScript first** — Full type safety with comprehensive type definitions
15
16
 
16
17
  ## Installation
17
18
 
18
19
  ```bash
19
20
  npm install bugstack-sdk
20
- # or
21
- pnpm add bugstack-sdk
22
- # or
23
- yarn add bugstack-sdk
24
21
  ```
25
22
 
26
23
  ## Quick Start
27
24
 
28
- ### 1. Initialize the client (once, in a shared file)
25
+ ### Next.js (App Router)
26
+
27
+ **1. Initialize the client once:**
29
28
 
30
29
  ```typescript
31
30
  // lib/bugstack.ts
32
31
  import { ErrorCaptureClient } from "bugstack-sdk";
33
32
 
34
- export const bugstack = ErrorCaptureClient.init({
33
+ ErrorCaptureClient.init({
35
34
  apiKey: process.env.BUGSTACK_API_KEY!,
36
- projectId: "my-project",
37
- // Optional: customize endpoint
38
- // endpoint: "https://your-bugstack-server.com/api/capture",
35
+ endpoint: "https://bugstack-error-service.onrender.com/api/capture",
39
36
  });
40
37
  ```
41
38
 
42
- ### 2. Wrap your API routes
39
+ **2. Wrap your API route handlers:**
43
40
 
44
41
  ```typescript
45
42
  // app/api/users/route.ts
46
43
  import { NextResponse } from "next/server";
47
- import { withErrorCapture } from "bugstack-sdk";
48
- import "@/lib/bugstack"; // Ensure client is initialized
44
+ import { withErrorCapture } from "bugstack-sdk/next";
45
+ import "@/lib/bugstack"; // ensures client is initialized
49
46
 
50
47
  export const GET = withErrorCapture(async (request) => {
51
48
  const users = await db.users.findMany();
@@ -59,32 +56,141 @@ export const POST = withErrorCapture(async (request) => {
59
56
  });
60
57
  ```
61
58
 
62
- ### 3. Dynamic routes with params
59
+ **3. Dynamic routes with params:**
63
60
 
64
61
  ```typescript
65
62
  // app/api/users/[id]/route.ts
66
63
  import { NextResponse } from "next/server";
67
- import { withErrorCapture } from "bugstack-sdk";
64
+ import { withErrorCapture } from "bugstack-sdk/next";
68
65
  import "@/lib/bugstack";
69
66
 
70
67
  export const GET = withErrorCapture<{ id: string }>(
71
68
  async (request, { params }) => {
72
- const user = await db.users.findUnique({
73
- where: { id: params.id },
74
- });
75
-
76
- if (!user) {
77
- throw new Error("User not found");
78
- }
79
-
69
+ const user = await db.users.findUnique({ where: { id: params.id } });
70
+ if (!user) throw new Error("User not found");
80
71
  return NextResponse.json({ user });
81
72
  }
82
73
  );
83
74
  ```
84
75
 
76
+ ---
77
+
78
+ ### Express
79
+
80
+ **Option A: Error handler middleware (recommended)**
81
+
82
+ ```typescript
83
+ import express from "express";
84
+ import { bugstackErrorHandler } from "bugstack-sdk/express";
85
+
86
+ const app = express();
87
+
88
+ // Your routes
89
+ app.get("/api/users", async (req, res) => {
90
+ const users = await db.users.findMany();
91
+ res.json({ users });
92
+ });
93
+
94
+ // Add BugStack error handler AFTER all routes
95
+ app.use(
96
+ bugstackErrorHandler({
97
+ apiKey: process.env.BUGSTACK_API_KEY!,
98
+ endpoint: "https://bugstack-error-service.onrender.com/api/capture",
99
+ })
100
+ );
101
+ ```
102
+
103
+ **Option B: Wrap individual route handlers**
104
+
105
+ ```typescript
106
+ import { initBugStack, wrapExpressHandler } from "bugstack-sdk/express";
107
+
108
+ // Initialize once
109
+ app.use(
110
+ initBugStack({
111
+ apiKey: process.env.BUGSTACK_API_KEY!,
112
+ endpoint: "https://bugstack-error-service.onrender.com/api/capture",
113
+ })
114
+ );
115
+
116
+ // Wrap specific routes
117
+ app.get("/api/users/:id", wrapExpressHandler(async (req, res) => {
118
+ const user = await getUser(req.params.id);
119
+ res.json(user);
120
+ }));
121
+ ```
122
+
123
+ ---
124
+
125
+ ### Generic Node.js
126
+
127
+ For any Node.js application (scripts, workers, serverless functions, etc.):
128
+
129
+ ```typescript
130
+ import { initBugStack, captureError, installGlobalHandlers } from "bugstack-sdk/generic";
131
+
132
+ // Initialize once
133
+ initBugStack({
134
+ apiKey: process.env.BUGSTACK_API_KEY!,
135
+ endpoint: "https://bugstack-error-service.onrender.com/api/capture",
136
+ });
137
+
138
+ // Optional: catch uncaught exceptions and unhandled rejections globally
139
+ installGlobalHandlers();
140
+
141
+ // Capture errors manually in try/catch blocks
142
+ try {
143
+ await processData();
144
+ } catch (error) {
145
+ await captureError(error, { operation: "processData" });
146
+ }
147
+ ```
148
+
149
+ **Wrap functions for automatic capture:**
150
+
151
+ ```typescript
152
+ import { wrapFunction } from "bugstack-sdk/generic";
153
+
154
+ const processData = wrapFunction(
155
+ async (data: Input) => {
156
+ // errors thrown here are automatically captured
157
+ return transform(data);
158
+ },
159
+ { operation: "processData" }
160
+ );
161
+ ```
162
+
163
+ **Create scoped capture functions:**
164
+
165
+ ```typescript
166
+ import { createErrorCapture } from "bugstack-sdk/generic";
167
+
168
+ const captureDbError = createErrorCapture({ component: "database" });
169
+
170
+ try {
171
+ await db.query("SELECT ...");
172
+ } catch (error) {
173
+ await captureDbError(error, { query: "SELECT ..." });
174
+ }
175
+ ```
176
+
177
+ ---
178
+
179
+ ## Other Languages
180
+
181
+ BugStack also provides SDKs for:
182
+
183
+ | Language | Package | Install |
184
+ |----------|---------|---------|
185
+ | Python | [bugstack](https://pypi.org/project/bugstack/) | `pip install bugstack` |
186
+ | Ruby | [bugstack](https://rubygems.org/gems/bugstack) | `gem install bugstack` |
187
+ | Go | [bugstack-go](https://github.com/MasonBachmann7/Bugstack-SDK-Go) | `go get github.com/MasonBachmann7/bugstack-go` |
188
+
189
+ ---
190
+
85
191
  ## Configuration
86
192
 
87
- ### Full Configuration Options
193
+ ### Full Options
88
194
 
89
195
  ```typescript
90
196
  import { ErrorCaptureClient } from "bugstack-sdk";
@@ -93,207 +199,128 @@ ErrorCaptureClient.init({
93
199
  // Required
94
200
  apiKey: "your-api-key",
95
201
 
96
- // Optional - defaults shown
97
- endpoint: "http://localhost:3001/api/capture",
202
+ // Endpoint (defaults to localhost for local dev)
203
+ endpoint: "https://bugstack-error-service.onrender.com/api/capture",
204
+
205
+ // Optional — defaults shown
98
206
  projectId: "",
99
- environment: process.env.NODE_ENV, // "development", "production", etc.
100
- enabled: true, // Set to false to disable capture
207
+ environment: process.env.NODE_ENV, // "development", "production", etc.
208
+ enabled: true, // set false to disable capture entirely
101
209
 
102
- // Request capture options
210
+ // Request capture
103
211
  captureRequestBody: true,
104
212
  captureQueryParams: true,
105
213
  captureHeaders: true,
106
- maxBodySize: 10000, // 10KB max body capture
214
+ maxBodySize: 10000, // 10KB max body capture
107
215
 
108
- // Additional fields to redact (added to defaults)
216
+ // Additional fields to redact (added to built-in defaults)
109
217
  redactFields: ["customSecret", "internalToken"],
110
218
 
111
219
  // Custom metadata included with every error
112
- metadata: {
113
- service: "api",
114
- version: "1.0.0",
115
- },
220
+ metadata: { service: "api", version: "1.0.0" },
116
221
 
117
- // Network options
118
- timeout: 5000, // 5 second timeout for error reporting
222
+ // Network
223
+ timeout: 5000, // 5s timeout for error reporting
224
+ deduplicationWindow: 5 * 60 * 1000, // 5 min window for dedup
119
225
 
120
226
  // Debug logging (defaults to true in development)
121
- debug: true,
227
+ debug: false,
122
228
 
123
- // Custom filter - return false to skip certain errors
229
+ // Custom filter — return false to skip certain errors
124
230
  shouldCapture: (error, request) => {
125
- // Don't capture 404s
126
- if (error.message.includes("not found")) {
127
- return false;
128
- }
231
+ if (error.message.includes("not found")) return false;
129
232
  return true;
130
233
  },
131
234
 
132
235
  // Transform errors before sending
133
236
  beforeSend: (capturedError) => {
134
- // Add custom data
135
- capturedError.metadata = {
136
- ...capturedError.metadata,
137
- customField: "value",
138
- };
139
- return capturedError;
140
- // Return null to skip this error
237
+ capturedError.metadata = { ...capturedError.metadata, custom: "value" };
238
+ return capturedError; // return null to skip
141
239
  },
142
240
  });
143
241
  ```
144
242
 
145
243
  ### Environment Variables
146
244
 
147
- The SDK automatically reads these environment variables:
245
+ The SDK reads these automatically:
148
246
 
149
247
  ```bash
150
- # Required
151
- BUGSTACK_API_KEY=your-api-key
152
-
153
- # Optional
154
- BUGSTACK_ENDPOINT=https://bugstack-error-service.onrender.com/api/capture
155
- BUGSTACK_PROJECT_ID=my-project
156
- NODE_ENV=production
248
+ BUGSTACK_API_KEY=your-api-key # Required
249
+ BUGSTACK_ENDPOINT=https://bugstack-error-service.onrender.com/api/capture # Optional
250
+ BUGSTACK_PROJECT_ID=my-project # Optional
251
+ NODE_ENV=production # Optional
157
252
  ```
158
253
 
159
- **Note:** The default endpoint is `http://localhost:3001/api/capture` for local development. Set `BUGSTACK_ENDPOINT` to the production URL shown above for deployed applications.
160
-
161
- ### Per-Route Options
162
-
163
- You can override options for specific routes:
254
+ ### Per-Route Options (Next.js)
164
255
 
165
256
  ```typescript
166
257
  export const POST = withErrorCapture(
167
- async (request) => {
168
- // handler code
169
- },
170
- undefined, // Use existing client config
258
+ async (request) => { /* ... */ },
259
+ undefined, // use existing client config
171
260
  {
172
- // Route-specific options
173
- statusCode: 400, // Report as 400 instead of 500
174
- metadata: {
175
- operation: "createUser",
176
- critical: true,
177
- },
178
- shouldCapture: (error) => {
179
- // Route-specific filter
180
- return error.name !== "ValidationError";
181
- },
261
+ statusCode: 400,
262
+ metadata: { operation: "createUser" },
263
+ shouldCapture: (error) => error.name !== "ValidationError",
182
264
  }
183
265
  );
184
266
  ```
185
267
 
186
- ## Captured Error Data
268
+ ---
187
269
 
188
- Each error report includes:
270
+ ## Automatic Sanitization
189
271
 
190
- ```typescript
191
- interface CapturedError {
192
- id: string; // Unique error ID (err_xxx_xxx)
193
- name: string; // Error name (TypeError, etc.)
194
- message: string; // Error message
195
- stack: string; // Full stack trace
196
- stackFrames: StackFrame[]; // Parsed stack frames
197
- timestamp: string; // ISO 8601 timestamp
198
- route: string; // API route path
199
- method: string; // HTTP method
200
- statusCode: number; // HTTP status code
201
- url: string; // Full request URL
202
- queryParams: object; // Query parameters (sanitized)
203
- requestBody: unknown; // Request body (sanitized)
204
- requestHeaders: object; // Headers (sanitized)
205
- routeParams: object; // Dynamic route params
206
- environment: string; // Environment name
207
- projectId: string; // Project identifier
208
- sdkVersion: string; // SDK version
209
- nodeVersion: string; // Node.js version
210
- nextVersion: string; // Next.js version
211
- metadata: object; // Custom metadata
212
- }
213
- ```
214
-
215
- ## Automatic Data Sanitization
216
-
217
- The SDK automatically redacts sensitive fields from:
218
- - Request headers (Authorization, Cookie, etc.)
219
- - Request body
220
- - Query parameters
221
-
222
- **Default redacted fields:**
223
- - password, secret, token
224
- - apikey, api_key, apiKey
225
- - authorization, auth, credential
226
- - credit_card, creditcard, card_number
227
- - cvv, ssn, social_security
228
-
229
- Add custom fields via `redactFields` config option.
272
+ The SDK redacts sensitive data from headers, request bodies, and query params.
230
273
 
231
- ## Error Handling
274
+ **Built-in redacted fields:**
275
+ `password`, `secret`, `token`, `apikey`, `api_key`, `apiKey`, `authorization`, `auth`, `credential`, `private`, `credit_card`, `creditcard`, `card_number`, `cvv`, `ssn`, `social_security`
232
276
 
233
- The SDK is designed to never interfere with your application:
234
-
235
- - **Network failures** - Silently ignored, your app continues normally
236
- - **Timeouts** - Configurable, defaults to 5 seconds
237
- - **SDK errors** - Caught and logged (in debug mode), never thrown
238
- - **Re-throws original error** - Next.js still handles the error response
239
-
240
- ## Advanced Usage
241
-
242
- ### Manual Error Reporting
243
-
244
- ```typescript
245
- import { ErrorCaptureClient } from "bugstack-sdk";
277
+ **Always-redacted headers:**
278
+ `authorization`, `cookie`, `set-cookie`, `x-api-key`, `x-auth-token`, `proxy-authorization`
246
279
 
247
- const client = ErrorCaptureClient.getInstance();
248
-
249
- if (client) {
250
- await client.reportError({
251
- id: "manual_001",
252
- name: "CustomError",
253
- message: "Something went wrong",
254
- timestamp: new Date().toISOString(),
255
- route: "/api/custom",
256
- method: "POST",
257
- statusCode: 500,
258
- url: "https://example.com/api/custom",
259
- environment: "production",
260
- sdkVersion: "1.0.0",
261
- nodeVersion: process.version,
262
- });
263
- }
264
- ```
280
+ Add custom fields via the `redactFields` config option.
265
281
 
266
- ### Stack Trace Utilities
282
+ ---
267
283
 
268
- ```typescript
269
- import {
270
- parseStackTrace,
271
- getFirstAppFrame,
272
- getAppFrames,
273
- } from "bugstack-sdk";
284
+ ## Error Resilience
274
285
 
275
- const frames = parseStackTrace(error.stack);
276
- const firstAppFrame = getFirstAppFrame(frames); // First non-node_modules frame
277
- const appFrames = getAppFrames(frames); // All application frames
278
- ```
286
+ The SDK never interferes with your application:
279
287
 
280
- ### Sanitization Utilities
288
+ - **Network failures** — Silently retried (up to 5 times with exponential backoff)
289
+ - **Timeouts** — Configurable, defaults to 5 seconds
290
+ - **SDK errors** — Caught and logged in debug mode, never thrown to your app
291
+ - **Original error preserved** — The wrapper re-throws the original error so your framework handles the response normally
281
292
 
282
- ```typescript
283
- import {
284
- sanitizeHeaders,
285
- sanitizeQueryParams,
286
- sanitizeObject,
287
- } from "bugstack-sdk";
293
+ ---
288
294
 
289
- const safeHeaders = sanitizeHeaders(request.headers);
290
- const safeParams = sanitizeQueryParams(new URL(request.url));
291
- const safeBody = sanitizeObject(requestBody);
292
- ```
295
+ ## Captured Data
293
296
 
294
- ## TypeScript Support
297
+ Each error report includes:
295
298
 
296
- Full type definitions are included:
299
+ | Field | Description |
300
+ |-------|-------------|
301
+ | `id` | Unique error ID |
302
+ | `fingerprint` | Stable hash for deduplication |
303
+ | `name` | Error type (TypeError, etc.) |
304
+ | `message` | Error message |
305
+ | `stack` | Full stack trace |
306
+ | `stackFrames` | Parsed stack frames with file, line, column |
307
+ | `route` | API route path |
308
+ | `method` | HTTP method |
309
+ | `statusCode` | HTTP status code |
310
+ | `url` | Full request URL |
311
+ | `queryParams` | Sanitized query parameters |
312
+ | `requestBody` | Sanitized request body |
313
+ | `requestHeaders` | Sanitized headers |
314
+ | `routeParams` | Dynamic route parameters |
315
+ | `environment` | Environment name |
316
+ | `projectId` | Project identifier |
317
+ | `metadata` | Custom metadata |
318
+
319
+ ---
320
+
321
+ ## TypeScript
322
+
323
+ All types are exported:
297
324
 
298
325
  ```typescript
299
326
  import type {
@@ -301,14 +328,16 @@ import type {
301
328
  CapturedError,
302
329
  StackFrame,
303
330
  RouteOptions,
304
- NextRouteHandler,
305
331
  RouteContext,
332
+ ErrorReportPayload,
333
+ SourceContext,
306
334
  } from "bugstack-sdk";
307
335
  ```
308
336
 
309
337
  ## Compatibility
310
338
 
311
339
  - **Next.js**: 14.0.0+
340
+ - **Express**: 4.x or 5.x
312
341
  - **Node.js**: 18.0.0+
313
342
  - **TypeScript**: 5.0.0+ (optional)
314
343
 
@@ -0,0 +1,80 @@
1
+ import { ErrorRequestHandler, Request, Response, NextFunction } from 'express';
2
+ import { b as ErrorCaptureConfig } from '../../client-9EMqVMOl.mjs';
3
+ export { B as BugStackClient, C as CapturedError, E as ErrorCaptureClient } from '../../client-9EMqVMOl.mjs';
4
+ import 'next/server';
5
+
6
+ /**
7
+ * BugStack SDK - Express Adapter
8
+ *
9
+ * Error capture middleware for Express.js applications
10
+ */
11
+
12
+ /**
13
+ * Express error handling middleware
14
+ *
15
+ * This middleware captures errors and reports them to BugStack.
16
+ * It must be registered AFTER all routes and other middleware.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import express from 'express';
21
+ * import { bugstackErrorHandler } from '@bugstack/sdk/express';
22
+ *
23
+ * const app = express();
24
+ *
25
+ * // ... your routes and middleware
26
+ *
27
+ * // Register BugStack error handler (must be last)
28
+ * app.use(bugstackErrorHandler({
29
+ * apiKey: 'your-api-key',
30
+ * projectId: 'your-project-id',
31
+ * autoFix: true
32
+ * }));
33
+ * ```
34
+ */
35
+ declare function bugstackErrorHandler(config?: ErrorCaptureConfig): ErrorRequestHandler;
36
+ /**
37
+ * Express middleware to initialize BugStack client
38
+ *
39
+ * Use this if you want to initialize the client separately from the error handler
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * import express from 'express';
44
+ * import { initBugStack, bugstackErrorHandler } from '@bugstack/sdk/express';
45
+ *
46
+ * const app = express();
47
+ *
48
+ * // Initialize client early
49
+ * app.use(initBugStack({
50
+ * apiKey: 'your-api-key',
51
+ * projectId: 'your-project-id',
52
+ * autoFix: true
53
+ * }));
54
+ *
55
+ * // ... your routes
56
+ *
57
+ * // Register error handler
58
+ * app.use(bugstackErrorHandler());
59
+ * ```
60
+ */
61
+ declare function initBugStack(config: ErrorCaptureConfig): (_req: Request, _res: Response, next: NextFunction) => void;
62
+ /**
63
+ * Wrap an Express route handler with error capture
64
+ *
65
+ * This is an alternative to using the error middleware. It catches errors
66
+ * in async route handlers and reports them to BugStack.
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * import { wrapExpressHandler } from '@bugstack/sdk/express';
71
+ *
72
+ * app.get('/api/users/:id', wrapExpressHandler(async (req, res) => {
73
+ * const user = await getUser(req.params.id);
74
+ * res.json(user);
75
+ * }));
76
+ * ```
77
+ */
78
+ declare function wrapExpressHandler(handler: (req: Request, res: Response, next: NextFunction) => Promise<void> | void): (req: Request, res: Response, next: NextFunction) => Promise<void>;
79
+
80
+ export { ErrorCaptureConfig, bugstackErrorHandler, initBugStack, wrapExpressHandler };
@@ -0,0 +1,80 @@
1
+ import { ErrorRequestHandler, Request, Response, NextFunction } from 'express';
2
+ import { b as ErrorCaptureConfig } from '../../client-9EMqVMOl.js';
3
+ export { B as BugStackClient, C as CapturedError, E as ErrorCaptureClient } from '../../client-9EMqVMOl.js';
4
+ import 'next/server';
5
+
6
+ /**
7
+ * BugStack SDK - Express Adapter
8
+ *
9
+ * Error capture middleware for Express.js applications
10
+ */
11
+
12
+ /**
13
+ * Express error handling middleware
14
+ *
15
+ * This middleware captures errors and reports them to BugStack.
16
+ * It must be registered AFTER all routes and other middleware.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import express from 'express';
21
+ * import { bugstackErrorHandler } from '@bugstack/sdk/express';
22
+ *
23
+ * const app = express();
24
+ *
25
+ * // ... your routes and middleware
26
+ *
27
+ * // Register BugStack error handler (must be last)
28
+ * app.use(bugstackErrorHandler({
29
+ * apiKey: 'your-api-key',
30
+ * projectId: 'your-project-id',
31
+ * autoFix: true
32
+ * }));
33
+ * ```
34
+ */
35
+ declare function bugstackErrorHandler(config?: ErrorCaptureConfig): ErrorRequestHandler;
36
+ /**
37
+ * Express middleware to initialize BugStack client
38
+ *
39
+ * Use this if you want to initialize the client separately from the error handler
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * import express from 'express';
44
+ * import { initBugStack, bugstackErrorHandler } from '@bugstack/sdk/express';
45
+ *
46
+ * const app = express();
47
+ *
48
+ * // Initialize client early
49
+ * app.use(initBugStack({
50
+ * apiKey: 'your-api-key',
51
+ * projectId: 'your-project-id',
52
+ * autoFix: true
53
+ * }));
54
+ *
55
+ * // ... your routes
56
+ *
57
+ * // Register error handler
58
+ * app.use(bugstackErrorHandler());
59
+ * ```
60
+ */
61
+ declare function initBugStack(config: ErrorCaptureConfig): (_req: Request, _res: Response, next: NextFunction) => void;
62
+ /**
63
+ * Wrap an Express route handler with error capture
64
+ *
65
+ * This is an alternative to using the error middleware. It catches errors
66
+ * in async route handlers and reports them to BugStack.
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * import { wrapExpressHandler } from '@bugstack/sdk/express';
71
+ *
72
+ * app.get('/api/users/:id', wrapExpressHandler(async (req, res) => {
73
+ * const user = await getUser(req.params.id);
74
+ * res.json(user);
75
+ * }));
76
+ * ```
77
+ */
78
+ declare function wrapExpressHandler(handler: (req: Request, res: Response, next: NextFunction) => Promise<void> | void): (req: Request, res: Response, next: NextFunction) => Promise<void>;
79
+
80
+ export { ErrorCaptureConfig, bugstackErrorHandler, initBugStack, wrapExpressHandler };