MCPcopy Index your code
hub / github.com/infinitered/reactotron / summarizeNetworkEntry

Function summarizeNetworkEntry

lib/reactotron-mcp/src/serialization.ts:111–141  ·  view source on GitHub ↗
(cmd: Command)

Source from the content-addressed store, hash-verified

109 * duration, and truncated previews of request/response bodies.
110 */
111export function summarizeNetworkEntry(cmd: Command): object {
112 const p = cmd.payload as any
113 const requestData = p?.request?.data != null
114 ? truncateValue(p.request.data, MAX_BODY_PREVIEW_CHARS)
115 : undefined
116 const responseBody = typeof p?.response?.body === "string"
117 ? (p.response.body.length > MAX_BODY_PREVIEW_CHARS
118 ? p.response.body.slice(0, MAX_BODY_PREVIEW_CHARS) + "..."
119 : p.response.body)
120 : p?.response?.body != null
121 ? truncateValue(p.response.body, MAX_BODY_PREVIEW_CHARS)
122 : undefined
123
124 return {
125 messageId: cmd.messageId,
126 clientId: cmd.clientId,
127 date: cmd.date,
128 duration: p?.duration,
129 request: {
130 method: p?.request?.method,
131 url: p?.request?.url,
132 headers: p?.request?.headers,
133 data: requestData,
134 },
135 response: {
136 status: p?.response?.status,
137 headers: p?.response?.headers,
138 body: responseBody,
139 },
140 }
141}
142
143/** Truncate any value to a compact JSON preview. */
144function truncateValue(value: unknown, limit: number): string {

Callers 2

registerResourcesFunction · 0.90

Calls 1

truncateValueFunction · 0.85

Tested by

no test coverage detected