@gokiteam/goki-dev 0.2.3 → 0.2.4
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
CHANGED
|
@@ -26,7 +26,9 @@ export const Schemas = {
|
|
|
26
26
|
sourceService: Joi.string(),
|
|
27
27
|
statusCode: Joi.number().integer(),
|
|
28
28
|
traceId: Joi.string(),
|
|
29
|
-
pathContains: Joi.string()
|
|
29
|
+
pathContains: Joi.string(),
|
|
30
|
+
since: Joi.string().isoDate(),
|
|
31
|
+
until: Joi.string().isoDate()
|
|
30
32
|
}).required(),
|
|
31
33
|
timeout: Joi.number().integer().min(100).max(30000).default(5000)
|
|
32
34
|
}),
|
|
@@ -45,7 +45,7 @@ export function registerHttpTrafficTools (server, apiClient) {
|
|
|
45
45
|
'http_traffic_wait_for',
|
|
46
46
|
'Wait for an HTTP traffic entry matching the filter to appear within a timeout (polling). Useful for e2e tests.',
|
|
47
47
|
{
|
|
48
|
-
filter: z.record(z.any()).describe('Required filter criteria (method, targetHost, sourceService, statusCode, traceId, pathContains)'),
|
|
48
|
+
filter: z.record(z.any()).describe('Required filter criteria (method, targetHost, sourceService, statusCode, traceId, pathContains, since, until). since/until are ISO date strings for time filtering.'),
|
|
49
49
|
timeout: z.number().optional().describe('Timeout in ms (default: 5000, max: 30000)')
|
|
50
50
|
},
|
|
51
51
|
{ readOnlyHint: true },
|
|
@@ -101,7 +101,7 @@ export const WebhookProxyMiddleware = () => {
|
|
|
101
101
|
const webhookMatch = ctx.path.match(/^\/v1\/webhooks\/([^/?]+)/)
|
|
102
102
|
if (webhookMatch) {
|
|
103
103
|
const endpoint = webhookMatch[1]
|
|
104
|
-
// Skip 'proxy' prefix - those
|
|
104
|
+
// Skip 'proxy' prefix - those are handled by resolveTarget with auto-routing fallback
|
|
105
105
|
if (endpoint !== 'proxy') {
|
|
106
106
|
resolved = {
|
|
107
107
|
target: 'http://gateway-webhook-app:3000',
|
|
@@ -110,11 +110,6 @@ export const WebhookProxyMiddleware = () => {
|
|
|
110
110
|
prefix: endpoint,
|
|
111
111
|
isAutoRouted: true
|
|
112
112
|
}
|
|
113
|
-
Logger.log({
|
|
114
|
-
level: 'info',
|
|
115
|
-
message: 'Webhook proxy: auto-routing to gateway-webhook',
|
|
116
|
-
data: { method: ctx.method, path: ctx.path, endpoint, target: resolved.target }
|
|
117
|
-
})
|
|
118
113
|
}
|
|
119
114
|
}
|
|
120
115
|
if (!resolved) {
|
|
@@ -133,6 +128,13 @@ export const WebhookProxyMiddleware = () => {
|
|
|
133
128
|
return
|
|
134
129
|
}
|
|
135
130
|
}
|
|
131
|
+
if (resolved.isAutoRouted) {
|
|
132
|
+
Logger.log({
|
|
133
|
+
level: 'info',
|
|
134
|
+
message: 'Webhook proxy: auto-routing to gateway-webhook',
|
|
135
|
+
data: { method: ctx.method, path: ctx.path, target: resolved.fullUrl }
|
|
136
|
+
})
|
|
137
|
+
}
|
|
136
138
|
const startTime = Date.now()
|
|
137
139
|
const queryParams = ctx.querystring ? Object.fromEntries(new URLSearchParams(ctx.querystring)) : null
|
|
138
140
|
// Buffer the raw request body so we can log it AND pass it to the proxy
|
|
@@ -174,7 +174,7 @@ class HttpProxyClass {
|
|
|
174
174
|
offset
|
|
175
175
|
}
|
|
176
176
|
if (filter && Object.keys(filter).length > 0) {
|
|
177
|
-
const { since, until, ...equalityFilter } = filter
|
|
177
|
+
const { since, until, targetHost, method, ...equalityFilter } = filter
|
|
178
178
|
if (Object.keys(equalityFilter).length > 0) {
|
|
179
179
|
listOptions.filter = equalityFilter
|
|
180
180
|
}
|
|
@@ -182,6 +182,14 @@ class HttpProxyClass {
|
|
|
182
182
|
const params = []
|
|
183
183
|
if (since) { conditions.push('created_at >= ?'); params.push(since) }
|
|
184
184
|
if (until) { conditions.push('created_at <= ?'); params.push(until) }
|
|
185
|
+
if (targetHost) {
|
|
186
|
+
conditions.push('(target_host = ? OR target_host LIKE ?)')
|
|
187
|
+
params.push(targetHost, `${targetHost}:%`)
|
|
188
|
+
}
|
|
189
|
+
if (method) {
|
|
190
|
+
conditions.push('UPPER(method) = UPPER(?)')
|
|
191
|
+
params.push(method)
|
|
192
|
+
}
|
|
185
193
|
if (conditions.length > 0) {
|
|
186
194
|
listOptions.rawWhere = { sql: conditions.join(' AND '), params }
|
|
187
195
|
}
|
|
@@ -134,7 +134,14 @@ class WebhookProxyClass {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
|
|
137
|
+
// Auto-route unregistered proxy paths to gateway-webhook
|
|
138
|
+
return {
|
|
139
|
+
target: 'http://gateway-webhook-app:3000',
|
|
140
|
+
path: pathAfterProxy,
|
|
141
|
+
fullUrl: `http://gateway-webhook-app:3000${pathAfterProxy}`,
|
|
142
|
+
prefix: 'auto',
|
|
143
|
+
isAutoRouted: true
|
|
144
|
+
}
|
|
138
145
|
}
|
|
139
146
|
|
|
140
147
|
logRequest (entry) {
|