@epic-js/express-profiler 0.1.1 → 0.1.3

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