@geekmidas/cli 0.10.0 → 0.13.0
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 +525 -0
- package/dist/bundler-B1qy9b-j.cjs +112 -0
- package/dist/bundler-B1qy9b-j.cjs.map +1 -0
- package/dist/bundler-DskIqW2t.mjs +111 -0
- package/dist/bundler-DskIqW2t.mjs.map +1 -0
- package/dist/{config-C9aXOHBe.cjs → config-AmInkU7k.cjs} +8 -8
- package/dist/config-AmInkU7k.cjs.map +1 -0
- package/dist/{config-BrkUalUh.mjs → config-DYULeEv8.mjs} +3 -3
- package/dist/config-DYULeEv8.mjs.map +1 -0
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +1 -1
- package/dist/encryption-C8H-38Yy.mjs +42 -0
- package/dist/encryption-C8H-38Yy.mjs.map +1 -0
- package/dist/encryption-Dyf_r1h-.cjs +44 -0
- package/dist/encryption-Dyf_r1h-.cjs.map +1 -0
- package/dist/index.cjs +2123 -179
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +2141 -192
- package/dist/index.mjs.map +1 -1
- package/dist/{openapi-CZLI4QTr.mjs → openapi-BfFlOBCG.mjs} +801 -38
- package/dist/openapi-BfFlOBCG.mjs.map +1 -0
- package/dist/{openapi-BeHLKcwP.cjs → openapi-Bt_1FDpT.cjs} +794 -31
- package/dist/openapi-Bt_1FDpT.cjs.map +1 -0
- package/dist/{openapi-react-query-o5iMi8tz.cjs → openapi-react-query-B-sNWHFU.cjs} +5 -5
- package/dist/openapi-react-query-B-sNWHFU.cjs.map +1 -0
- package/dist/{openapi-react-query-CcciaVu5.mjs → openapi-react-query-B6XTeGqS.mjs} +5 -5
- package/dist/openapi-react-query-B6XTeGqS.mjs.map +1 -0
- package/dist/openapi-react-query.cjs +1 -1
- package/dist/openapi-react-query.d.cts.map +1 -1
- package/dist/openapi-react-query.d.mts.map +1 -1
- package/dist/openapi-react-query.mjs +1 -1
- package/dist/openapi.cjs +2 -2
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.cts.map +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.d.mts.map +1 -1
- package/dist/openapi.mjs +2 -2
- package/dist/storage-BOOpAF8N.cjs +5 -0
- package/dist/storage-Bj1E26lU.cjs +187 -0
- package/dist/storage-Bj1E26lU.cjs.map +1 -0
- package/dist/storage-kSxTjkNb.mjs +133 -0
- package/dist/storage-kSxTjkNb.mjs.map +1 -0
- package/dist/storage-tgZSUnKl.mjs +3 -0
- package/dist/{types-b-vwGpqc.d.cts → types-BR0M2v_c.d.mts} +100 -1
- package/dist/types-BR0M2v_c.d.mts.map +1 -0
- package/dist/{types-DXgiA1sF.d.mts → types-BhkZc-vm.d.cts} +100 -1
- package/dist/types-BhkZc-vm.d.cts.map +1 -0
- package/examples/cron-example.ts +27 -27
- package/examples/env.ts +27 -27
- package/examples/function-example.ts +31 -31
- package/examples/gkm.config.json +20 -20
- package/examples/gkm.config.ts +8 -8
- package/examples/gkm.minimal.config.json +5 -5
- package/examples/gkm.production.config.json +25 -25
- package/examples/logger.ts +2 -2
- package/package.json +6 -6
- package/src/__tests__/EndpointGenerator.hooks.spec.ts +191 -191
- package/src/__tests__/config.spec.ts +55 -55
- package/src/__tests__/loadEnvFiles.spec.ts +93 -93
- package/src/__tests__/normalizeHooksConfig.spec.ts +58 -58
- package/src/__tests__/openapi-react-query.spec.ts +497 -497
- package/src/__tests__/openapi.spec.ts +428 -428
- package/src/__tests__/test-helpers.ts +76 -76
- package/src/auth/__tests__/credentials.spec.ts +204 -0
- package/src/auth/__tests__/index.spec.ts +168 -0
- package/src/auth/credentials.ts +187 -0
- package/src/auth/index.ts +226 -0
- package/src/build/__tests__/bundler.spec.ts +444 -0
- package/src/build/__tests__/index-new.spec.ts +474 -474
- package/src/build/__tests__/manifests.spec.ts +333 -333
- package/src/build/bundler.ts +210 -0
- package/src/build/endpoint-analyzer.ts +236 -0
- package/src/build/handler-templates.ts +1253 -0
- package/src/build/index.ts +260 -179
- package/src/build/manifests.ts +52 -52
- package/src/build/providerResolver.ts +145 -145
- package/src/build/types.ts +64 -43
- package/src/config.ts +39 -39
- package/src/deploy/__tests__/docker.spec.ts +111 -0
- package/src/deploy/__tests__/dokploy.spec.ts +245 -0
- package/src/deploy/__tests__/init.spec.ts +662 -0
- package/src/deploy/docker.ts +128 -0
- package/src/deploy/dokploy.ts +204 -0
- package/src/deploy/index.ts +136 -0
- package/src/deploy/init.ts +484 -0
- package/src/deploy/types.ts +48 -0
- package/src/dev/__tests__/index.spec.ts +266 -266
- package/src/dev/index.ts +647 -601
- package/src/docker/__tests__/compose.spec.ts +531 -0
- package/src/docker/__tests__/templates.spec.ts +280 -0
- package/src/docker/compose.ts +273 -0
- package/src/docker/index.ts +230 -0
- package/src/docker/templates.ts +446 -0
- package/src/generators/CronGenerator.ts +72 -72
- package/src/generators/EndpointGenerator.ts +699 -398
- package/src/generators/FunctionGenerator.ts +84 -84
- package/src/generators/Generator.ts +72 -72
- package/src/generators/OpenApiTsGenerator.ts +577 -577
- package/src/generators/SubscriberGenerator.ts +124 -124
- package/src/generators/__tests__/CronGenerator.spec.ts +433 -433
- package/src/generators/__tests__/EndpointGenerator.spec.ts +532 -382
- package/src/generators/__tests__/FunctionGenerator.spec.ts +244 -244
- package/src/generators/__tests__/SubscriberGenerator.spec.ts +397 -382
- package/src/generators/index.ts +4 -4
- package/src/index.ts +623 -201
- package/src/init/__tests__/generators.spec.ts +334 -334
- package/src/init/__tests__/init.spec.ts +332 -332
- package/src/init/__tests__/utils.spec.ts +89 -89
- package/src/init/generators/config.ts +175 -175
- package/src/init/generators/docker.ts +41 -41
- package/src/init/generators/env.ts +72 -72
- package/src/init/generators/index.ts +1 -1
- package/src/init/generators/models.ts +64 -64
- package/src/init/generators/monorepo.ts +161 -161
- package/src/init/generators/package.ts +71 -71
- package/src/init/generators/source.ts +6 -6
- package/src/init/index.ts +203 -208
- package/src/init/templates/api.ts +115 -115
- package/src/init/templates/index.ts +75 -75
- package/src/init/templates/minimal.ts +98 -98
- package/src/init/templates/serverless.ts +89 -89
- package/src/init/templates/worker.ts +98 -98
- package/src/init/utils.ts +54 -56
- package/src/openapi-react-query.ts +194 -194
- package/src/openapi.ts +63 -63
- package/src/secrets/__tests__/encryption.spec.ts +226 -0
- package/src/secrets/__tests__/generator.spec.ts +319 -0
- package/src/secrets/__tests__/index.spec.ts +91 -0
- package/src/secrets/__tests__/storage.spec.ts +611 -0
- package/src/secrets/encryption.ts +91 -0
- package/src/secrets/generator.ts +164 -0
- package/src/secrets/index.ts +383 -0
- package/src/secrets/storage.ts +192 -0
- package/src/secrets/types.ts +53 -0
- package/src/types.ts +295 -176
- package/tsdown.config.ts +11 -8
- package/dist/config-BrkUalUh.mjs.map +0 -1
- package/dist/config-C9aXOHBe.cjs.map +0 -1
- package/dist/openapi-BeHLKcwP.cjs.map +0 -1
- package/dist/openapi-CZLI4QTr.mjs.map +0 -1
- package/dist/openapi-react-query-CcciaVu5.mjs.map +0 -1
- package/dist/openapi-react-query-o5iMi8tz.cjs.map +0 -1
- package/dist/types-DXgiA1sF.d.mts.map +0 -1
- package/dist/types-b-vwGpqc.d.cts.map +0 -1
|
@@ -2,9 +2,9 @@ import type { AddressInfo } from 'node:net';
|
|
|
2
2
|
import { createServer } from 'node:net';
|
|
3
3
|
import { afterEach, describe, expect, it } from 'vitest';
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
findAvailablePort,
|
|
6
|
+
isPortAvailable,
|
|
7
|
+
normalizeTelescopeConfig,
|
|
8
8
|
} from '../index';
|
|
9
9
|
|
|
10
10
|
// Skip port-related tests in CI due to flaky port binding issues
|
|
@@ -14,18 +14,18 @@ const describePortTests = process.env.CI ? describe.skip : describe;
|
|
|
14
14
|
const activeServers: ReturnType<typeof createServer>[] = [];
|
|
15
15
|
|
|
16
16
|
afterEach(async () => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
// Close all servers and wait for them to fully close
|
|
18
|
+
await Promise.all(
|
|
19
|
+
activeServers.map(
|
|
20
|
+
(server) =>
|
|
21
|
+
new Promise<void>((resolve) => {
|
|
22
|
+
server.close(() => resolve());
|
|
23
|
+
}),
|
|
24
|
+
),
|
|
25
|
+
);
|
|
26
|
+
activeServers.length = 0;
|
|
27
|
+
// Give OS time to release ports
|
|
28
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -33,271 +33,271 @@ afterEach(async () => {
|
|
|
33
33
|
* Pass port 0 to get a random available port.
|
|
34
34
|
*/
|
|
35
35
|
function occupyPort(
|
|
36
|
-
|
|
36
|
+
port: number,
|
|
37
37
|
): Promise<{ server: ReturnType<typeof createServer>; port: number }> {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
const server = createServer();
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
server.once('error', (err) => {
|
|
42
|
+
reject(err);
|
|
43
|
+
});
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
server.once('listening', () => {
|
|
46
|
+
activeServers.push(server);
|
|
47
|
+
const actualPort = (server.address() as AddressInfo).port;
|
|
48
|
+
resolve({ server, port: actualPort });
|
|
49
|
+
});
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
server.listen(port);
|
|
52
|
+
});
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
describePortTests('Port Availability Functions', () => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
56
|
+
describe('isPortAvailable', () => {
|
|
57
|
+
it('should return true for an available port', async () => {
|
|
58
|
+
// Get a random port, close it, then check availability
|
|
59
|
+
const { server, port } = await occupyPort(0);
|
|
60
|
+
server.close();
|
|
61
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
62
|
+
|
|
63
|
+
const available = await isPortAvailable(port);
|
|
64
|
+
expect(available).toBe(true);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should return false for a port in use', async () => {
|
|
68
|
+
const { port } = await occupyPort(0);
|
|
69
|
+
|
|
70
|
+
const available = await isPortAvailable(port);
|
|
71
|
+
expect(available).toBe(false);
|
|
72
|
+
// Server cleanup handled by afterEach
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should handle multiple sequential checks correctly', async () => {
|
|
76
|
+
// Get a port to test with
|
|
77
|
+
const { server: tempServer, port } = await occupyPort(0);
|
|
78
|
+
tempServer.close();
|
|
79
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
80
|
+
|
|
81
|
+
// First check - port should be available
|
|
82
|
+
const firstCheck = await isPortAvailable(port);
|
|
83
|
+
expect(firstCheck).toBe(true);
|
|
84
|
+
|
|
85
|
+
// Occupy the port
|
|
86
|
+
await occupyPort(port);
|
|
87
|
+
|
|
88
|
+
// Second check - port should be unavailable
|
|
89
|
+
const secondCheck = await isPortAvailable(port);
|
|
90
|
+
expect(secondCheck).toBe(false);
|
|
91
|
+
// Server cleanup and third check handled by afterEach
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe('findAvailablePort', () => {
|
|
96
|
+
it('should return the preferred port if available', async () => {
|
|
97
|
+
// Get a random port, close it, then use as preferred
|
|
98
|
+
const { server, port: preferredPort } = await occupyPort(0);
|
|
99
|
+
server.close();
|
|
100
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
101
|
+
|
|
102
|
+
const foundPort = await findAvailablePort(preferredPort);
|
|
103
|
+
expect(foundPort).toBe(preferredPort);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should return the next available port if preferred is in use', async () => {
|
|
107
|
+
const { port: preferredPort } = await occupyPort(0);
|
|
108
|
+
|
|
109
|
+
const foundPort = await findAvailablePort(preferredPort);
|
|
110
|
+
expect(foundPort).toBe(preferredPort + 1);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('should skip multiple occupied ports', async () => {
|
|
114
|
+
// Get a base port
|
|
115
|
+
const { port: basePort } = await occupyPort(0);
|
|
116
|
+
// Occupy consecutive ports
|
|
117
|
+
await occupyPort(basePort + 1);
|
|
118
|
+
await occupyPort(basePort + 2);
|
|
119
|
+
|
|
120
|
+
const foundPort = await findAvailablePort(basePort);
|
|
121
|
+
expect(foundPort).toBe(basePort + 3);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('should throw error if no available port found within max attempts', async () => {
|
|
125
|
+
const { port: preferredPort } = await occupyPort(0);
|
|
126
|
+
const maxAttempts = 3;
|
|
127
|
+
|
|
128
|
+
// Occupy consecutive ports
|
|
129
|
+
await occupyPort(preferredPort + 1);
|
|
130
|
+
await occupyPort(preferredPort + 2);
|
|
131
|
+
|
|
132
|
+
await expect(
|
|
133
|
+
findAvailablePort(preferredPort, maxAttempts),
|
|
134
|
+
).rejects.toThrow(
|
|
135
|
+
`Could not find an available port after trying ${maxAttempts} ports starting from ${preferredPort}`,
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should respect custom maxAttempts parameter', async () => {
|
|
140
|
+
const { port: preferredPort } = await occupyPort(0);
|
|
141
|
+
const maxAttempts = 5;
|
|
142
|
+
|
|
143
|
+
// Occupy consecutive ports (4 total including base)
|
|
144
|
+
await occupyPort(preferredPort + 1);
|
|
145
|
+
await occupyPort(preferredPort + 2);
|
|
146
|
+
await occupyPort(preferredPort + 3);
|
|
147
|
+
|
|
148
|
+
const foundPort = await findAvailablePort(preferredPort, maxAttempts);
|
|
149
|
+
// Should find port at preferredPort + 4 (within 5 attempts)
|
|
150
|
+
expect(foundPort).toBe(preferredPort + 4);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
153
|
});
|
|
154
154
|
|
|
155
155
|
describePortTests('DevServer', () => {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
156
|
+
describe('port selection', () => {
|
|
157
|
+
it('should use requested port when available', async () => {
|
|
158
|
+
// Get a random port, close it, then use as requested
|
|
159
|
+
const { server, port: requestedPort } = await occupyPort(0);
|
|
160
|
+
server.close();
|
|
161
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
162
|
+
|
|
163
|
+
const actualPort = await findAvailablePort(requestedPort);
|
|
164
|
+
expect(actualPort).toBe(requestedPort);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('should select alternative port when requested is in use', async () => {
|
|
168
|
+
const { port: requestedPort } = await occupyPort(0);
|
|
169
|
+
|
|
170
|
+
const actualPort = await findAvailablePort(requestedPort);
|
|
171
|
+
expect(actualPort).not.toBe(requestedPort);
|
|
172
|
+
expect(actualPort).toBeGreaterThan(requestedPort);
|
|
173
|
+
expect(actualPort).toBeLessThanOrEqual(requestedPort + 10);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
176
|
});
|
|
177
177
|
|
|
178
178
|
describePortTests('devCommand edge cases', () => {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
179
|
+
it('should handle port conflicts gracefully', async () => {
|
|
180
|
+
const { port } = await occupyPort(0);
|
|
181
|
+
|
|
182
|
+
// The dev command should find an alternative port
|
|
183
|
+
const alternativePort = await findAvailablePort(port);
|
|
184
|
+
expect(alternativePort).toBeGreaterThan(port);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('should handle concurrent port checks', async () => {
|
|
188
|
+
// Get three random available ports as base
|
|
189
|
+
const { server: s1, port: p1 } = await occupyPort(0);
|
|
190
|
+
const { server: s2, port: p2 } = await occupyPort(0);
|
|
191
|
+
const { server: s3, port: p3 } = await occupyPort(0);
|
|
192
|
+
s1.close();
|
|
193
|
+
s2.close();
|
|
194
|
+
s3.close();
|
|
195
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
196
|
+
|
|
197
|
+
// Run multiple port checks concurrently
|
|
198
|
+
const results = await Promise.all([
|
|
199
|
+
findAvailablePort(p1),
|
|
200
|
+
findAvailablePort(p2),
|
|
201
|
+
findAvailablePort(p3),
|
|
202
|
+
]);
|
|
203
|
+
|
|
204
|
+
// All should succeed and return valid ports
|
|
205
|
+
expect(results).toHaveLength(3);
|
|
206
|
+
expect(results[0]).toBe(p1);
|
|
207
|
+
expect(results[1]).toBe(p2);
|
|
208
|
+
expect(results[2]).toBe(p3);
|
|
209
|
+
});
|
|
210
210
|
});
|
|
211
211
|
|
|
212
212
|
describe('normalizeTelescopeConfig', () => {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
213
|
+
it('should return undefined when config is false', () => {
|
|
214
|
+
const result = normalizeTelescopeConfig(false);
|
|
215
|
+
expect(result).toBeUndefined();
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it('should return default config when config is true', () => {
|
|
219
|
+
const result = normalizeTelescopeConfig(true);
|
|
220
|
+
expect(result).toEqual({
|
|
221
|
+
enabled: true,
|
|
222
|
+
path: '/__telescope',
|
|
223
|
+
ignore: [],
|
|
224
|
+
recordBody: true,
|
|
225
|
+
maxEntries: 1000,
|
|
226
|
+
websocket: true,
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it('should return default config when config is undefined', () => {
|
|
231
|
+
const result = normalizeTelescopeConfig(undefined);
|
|
232
|
+
expect(result).toEqual({
|
|
233
|
+
enabled: true,
|
|
234
|
+
path: '/__telescope',
|
|
235
|
+
ignore: [],
|
|
236
|
+
recordBody: true,
|
|
237
|
+
maxEntries: 1000,
|
|
238
|
+
websocket: true,
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('should return undefined when config.enabled is false', () => {
|
|
243
|
+
const result = normalizeTelescopeConfig({ enabled: false });
|
|
244
|
+
expect(result).toBeUndefined();
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('should merge custom config with defaults', () => {
|
|
248
|
+
const result = normalizeTelescopeConfig({
|
|
249
|
+
path: '/__debug',
|
|
250
|
+
ignore: ['/health', '/metrics'],
|
|
251
|
+
recordBody: false,
|
|
252
|
+
maxEntries: 500,
|
|
253
|
+
});
|
|
254
|
+
expect(result).toEqual({
|
|
255
|
+
enabled: true,
|
|
256
|
+
path: '/__debug',
|
|
257
|
+
ignore: ['/health', '/metrics'],
|
|
258
|
+
recordBody: false,
|
|
259
|
+
maxEntries: 500,
|
|
260
|
+
websocket: true,
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it('should use defaults for missing config values', () => {
|
|
265
|
+
const result = normalizeTelescopeConfig({
|
|
266
|
+
path: '/__custom',
|
|
267
|
+
});
|
|
268
|
+
expect(result).toEqual({
|
|
269
|
+
enabled: true,
|
|
270
|
+
path: '/__custom',
|
|
271
|
+
ignore: [],
|
|
272
|
+
recordBody: true,
|
|
273
|
+
maxEntries: 1000,
|
|
274
|
+
websocket: true,
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it('should handle empty object config', () => {
|
|
279
|
+
const result = normalizeTelescopeConfig({});
|
|
280
|
+
expect(result).toEqual({
|
|
281
|
+
enabled: true,
|
|
282
|
+
path: '/__telescope',
|
|
283
|
+
ignore: [],
|
|
284
|
+
recordBody: true,
|
|
285
|
+
maxEntries: 1000,
|
|
286
|
+
websocket: true,
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('should allow disabling websocket', () => {
|
|
291
|
+
const result = normalizeTelescopeConfig({
|
|
292
|
+
websocket: false,
|
|
293
|
+
});
|
|
294
|
+
expect(result).toEqual({
|
|
295
|
+
enabled: true,
|
|
296
|
+
path: '/__telescope',
|
|
297
|
+
ignore: [],
|
|
298
|
+
recordBody: true,
|
|
299
|
+
maxEntries: 1000,
|
|
300
|
+
websocket: false,
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
303
|
});
|