@epic-js/express-profiler 0.1.1 → 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.
- package/README.md +27 -1
- 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
|
-
|
|
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,28 @@ app.get('/users', async (req, res) => {
|
|
|
25
29
|
});
|
|
26
30
|
```
|
|
27
31
|
|
|
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
|
|
52
|
+
```
|
|
53
|
+
|
|
28
54
|
## CLI Usage
|
|
29
55
|
```
|
|
30
56
|
express-profiler-cli logs.json
|