@epic-js/express-profiler 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +30 -3
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -10,18 +10,45 @@ npm install express-profiler
10
10
  ## Usage
11
11
  ```js
12
12
  const express = require('express');
13
- const expressProfiler = require('express-profiler');
14
- const { wrapAsync } = require('express-profiler/wrappers');
13
+ const apiProfiler = require('@epic-js/express-profiler');
15
14
 
16
15
  const app = express();
17
16
  app.use(expressProfiler());
17
+ ```
18
+
19
+ ## Output
20
+ ```bash
21
+ POST /reverseGeoCoding 200 279.9ms
22
+ ```
18
23
 
24
+ ## After finding the slow routes dig deeper by using the wrapAsync
25
+ ```js
19
26
  app.get('/users', async (req, res) => {
20
27
  const users = await wrapAsync(async () => [{ id: 1, name: 'Alice' }], 'DB', req)();
21
28
  res.send(users);
22
29
  });
30
+ ```
23
31
 
24
- app.listen(3000);
32
+ ## Output
33
+ ```bash
34
+ POST /reverseGeoCoding 200 279.9ms
35
+ ```
36
+
37
+ ## Usage
38
+ ```bash
39
+ app.get('/slow', async (req, res) => {
40
+ const dbTask = wrapAsync(() => new Promise(r => setTimeout(r, 300)), 'DB', req);
41
+ const apiTask = wrapAsync(() => new Promise(r => setTimeout(r, 200)), 'External API', req);
42
+
43
+ await dbTask();
44
+ await apiTask();
45
+ res.send('Slow route done');
46
+ });
47
+ ```
48
+ ```bash
49
+ GET /slow 200 518.3ms
50
+ DB: 309.1ms
51
+ External API: 203.9ms
25
52
  ```
26
53
 
27
54
  ## CLI Usage
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epic-js/express-profiler",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Lightweight Express API profiler with route/middleware/async timing",
5
5
  "main": "index.js",
6
6
  "bin": {