refactor: share platform file and route helpers
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { parseProxyLogMetadata } from '../../../shared/proxyLogMeta.js';
|
||||
|
||||
type ComposeProxyLogMessageArgs = {
|
||||
clientKind?: string | null;
|
||||
sessionId?: string | null;
|
||||
@@ -16,21 +18,7 @@ export type ParsedProxyLogMessageMeta = {
|
||||
};
|
||||
|
||||
export function parseProxyLogMessageMeta(rawMessage: string): ParsedProxyLogMessageMeta {
|
||||
const clientMatch = rawMessage.match(/\[client:([^\]]+)\]/i);
|
||||
const sessionMatch = rawMessage.match(/\[session:([^\]]+)\]/i);
|
||||
const downstreamMatch = rawMessage.match(/\[downstream:([^\]]+)\]/i);
|
||||
const upstreamMatch = rawMessage.match(/\[upstream:([^\]]+)\]/i);
|
||||
const messageText = rawMessage.replace(
|
||||
/^\s*(?:\[(?:client|session|downstream|upstream):[^\]]+\]\s*)+/i,
|
||||
'',
|
||||
).trim();
|
||||
return {
|
||||
clientKind: clientMatch?.[1]?.trim() || null,
|
||||
sessionId: sessionMatch?.[1]?.trim() || null,
|
||||
downstreamPath: downstreamMatch?.[1]?.trim() || null,
|
||||
upstreamPath: upstreamMatch?.[1]?.trim() || null,
|
||||
messageText,
|
||||
};
|
||||
return parseProxyLogMetadata(rawMessage);
|
||||
}
|
||||
|
||||
export function composeProxyLogMessage({
|
||||
|
||||
Reference in New Issue
Block a user