api-observe 1.1.0 → 1.1.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.
@@ -12,7 +12,7 @@ function getDashboardHtml() {
12
12
  <head>
13
13
  <meta charset="UTF-8">
14
14
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
15
- <title>ps-observe | API Failure Tracker</title>
15
+ <title>observe | API Failure Tracker</title>
16
16
  <style>
17
17
  * { margin: 0; padding: 0; box-sizing: border-box; }
18
18
 
@@ -306,7 +306,7 @@ function getDashboardHtml() {
306
306
  </head>
307
307
  <body>
308
308
  <header>
309
- <h1>ps-observe</h1>
309
+ <h1>observe</h1>
310
310
  <div class="stats">
311
311
  <span class="count" id="totalCount">0</span> failures tracked
312
312
  </div>
@@ -329,6 +329,7 @@ function getDashboardHtml() {
329
329
  </select>
330
330
  <input type="number" id="filterStatus" placeholder="Status code..." min="100" max="599" />
331
331
  <input type="text" id="filterUrl" placeholder="URL contains..." />
332
+ <input type="text" id="filterCorrelationId" placeholder="Correlation ID..." />
332
333
  <button class="refresh-btn" onclick="loadFailures()">Refresh</button>
333
334
  <button class="danger" onclick="clearAll()">Clear All</button>
334
335
  </div>
@@ -373,12 +374,14 @@ function getDashboardHtml() {
373
374
  const method = document.getElementById('filterMethod').value;
374
375
  const statusCode = document.getElementById('filterStatus').value;
375
376
  const url = document.getElementById('filterUrl').value;
377
+ const correlationId = document.getElementById('filterCorrelationId').value.trim();
376
378
 
377
379
  if (type) params.set('type', type);
378
380
  if (service) params.set('service', service);
379
381
  if (method) params.set('method', method);
380
382
  if (statusCode) params.set('statusCode', statusCode);
381
383
  if (url) params.set('url', url);
384
+ if (correlationId) params.set('correlationId', correlationId);
382
385
  params.set('limit', PAGE_SIZE);
383
386
  params.set('offset', currentOffset);
384
387
 
@@ -46,7 +46,7 @@ class FailureStore {
46
46
 
47
47
  /**
48
48
  * Query failures with optional filters.
49
- * @param {{ service?: string, statusCode?: number, from?: string, to?: string, method?: string, url?: string, limit?: number, offset?: number }} [filters]
49
+ * @param {{ service?: string, statusCode?: number, from?: string, to?: string, method?: string, url?: string, correlationId?: string, limit?: number, offset?: number }} [filters]
50
50
  * @returns {{ data: object[], total: number }}
51
51
  */
52
52
  query(filters = {}) {
@@ -81,6 +81,10 @@ class FailureStore {
81
81
  const url = filters.url.toLowerCase();
82
82
  results = results.filter(e => e.url?.toLowerCase().includes(url));
83
83
  }
84
+ if (filters.correlationId) {
85
+ const cid = String(filters.correlationId).toLowerCase();
86
+ results = results.filter(e => e.correlationId?.toLowerCase().includes(cid));
87
+ }
84
88
  if (filters.from) {
85
89
  const from = new Date(filters.from).getTime();
86
90
  results = results.filter(e => new Date(e.timestamp).getTime() >= from);
package/lib/router.js CHANGED
@@ -42,8 +42,8 @@ function createRouter(store) {
42
42
 
43
43
  // ── List failures ──────────────────────────────────────────────────────
44
44
  if (method === 'GET' && path === '/observe/api/failures') {
45
- const { service, statusCode, method: m, url, from, to, limit, offset, type } = query || {};
46
- const result = store.query({ service, statusCode, method: m, url, from, to, limit, offset, type });
45
+ const { service, statusCode, method: m, url, from, to, limit, offset, type, correlationId } = query || {};
46
+ const result = store.query({ service, statusCode, method: m, url, from, to, limit, offset, type, correlationId });
47
47
  return { status: 200, headers: { 'content-type': 'application/json' }, body: result };
48
48
  }
49
49
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-observe",
3
- "version": "1.1.0",
3
+ "version": "1.1.01",
4
4
  "description": "Framework-agnostic plugin that captures and displays API failure details — works with Fastify, Express, NestJS, Koa, or plain Node.js HTTP",
5
5
  "main": "lib/index.js",
6
6
  "files": [