@usageflow/express 0.4.1 → 0.4.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/package.json +2 -2
- package/test/plugin.test.ts +4 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usageflow/express",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "UsageFlow plugin for Express applications",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@usageflow/core": "^0.4.
|
|
17
|
+
"@usageflow/core": "^0.4.2",
|
|
18
18
|
"@usageflow/logger": "^0.1.1",
|
|
19
19
|
"express": "^4.18.0",
|
|
20
20
|
"ws": "^8.16.0"
|
package/test/plugin.test.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { test, describe, beforeEach, afterEach } from 'node:test';
|
|
2
2
|
import assert from 'node:assert';
|
|
3
3
|
import { ExpressUsageFlowAPI } from '../src/plugin';
|
|
4
|
-
import { Route } from '@usageflow/core';
|
|
5
4
|
|
|
6
5
|
describe('ExpressUsageFlowAPI', () => {
|
|
7
6
|
let api: ExpressUsageFlowAPI;
|
|
@@ -27,36 +26,13 @@ describe('ExpressUsageFlowAPI', () => {
|
|
|
27
26
|
});
|
|
28
27
|
|
|
29
28
|
test('should create middleware', () => {
|
|
30
|
-
const
|
|
31
|
-
{ method: 'GET', url: '/users' }
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
const middleware = api.createMiddleware(routes);
|
|
29
|
+
const middleware = api.createMiddleware();
|
|
35
30
|
assert.strictEqual(typeof middleware, 'function');
|
|
36
31
|
assert.strictEqual(middleware.length, 3); // Express middleware signature
|
|
37
32
|
});
|
|
38
33
|
|
|
39
|
-
test('should create middleware with whitelist', () => {
|
|
40
|
-
const routes: Route[] = [
|
|
41
|
-
{ method: '*', url: '*' }
|
|
42
|
-
];
|
|
43
|
-
const whitelistRoutes: Route[] = [
|
|
44
|
-
{ method: 'GET', url: '/health' }
|
|
45
|
-
];
|
|
46
|
-
|
|
47
|
-
const middleware = api.createMiddleware(routes, whitelistRoutes);
|
|
48
|
-
assert.strictEqual(typeof middleware, 'function');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
34
|
test.skip('should skip whitelisted routes', async () => {
|
|
52
|
-
const
|
|
53
|
-
{ method: '*', url: '*' }
|
|
54
|
-
];
|
|
55
|
-
const whitelistRoutes: Route[] = [
|
|
56
|
-
{ method: 'GET', url: '/health' }
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
const middleware = api.createMiddleware(routes, whitelistRoutes);
|
|
35
|
+
const middleware = api.createMiddleware();
|
|
60
36
|
|
|
61
37
|
const req: any = {
|
|
62
38
|
method: 'GET',
|
|
@@ -94,11 +70,7 @@ describe('ExpressUsageFlowAPI', () => {
|
|
|
94
70
|
});
|
|
95
71
|
|
|
96
72
|
test('should monitor matching routes', async () => {
|
|
97
|
-
const
|
|
98
|
-
{ method: 'GET', url: '/users' }
|
|
99
|
-
];
|
|
100
|
-
|
|
101
|
-
const middleware = api.createMiddleware(routes);
|
|
73
|
+
const middleware = api.createMiddleware();
|
|
102
74
|
|
|
103
75
|
const req: any = {
|
|
104
76
|
method: 'GET',
|
|
@@ -152,11 +124,7 @@ describe('ExpressUsageFlowAPI', () => {
|
|
|
152
124
|
destroy() { }
|
|
153
125
|
} as any;
|
|
154
126
|
|
|
155
|
-
const
|
|
156
|
-
{ method: 'GET', url: '/users' }
|
|
157
|
-
];
|
|
158
|
-
|
|
159
|
-
const middleware = api.createMiddleware(routes);
|
|
127
|
+
const middleware = api.createMiddleware();
|
|
160
128
|
|
|
161
129
|
const req: any = {
|
|
162
130
|
method: 'GET',
|