MCPcopy Index your code
hub / github.com/freeCodeCamp/freeCodeCamp / captureReply

Function captureReply

api/src/plugins/shadow-capture.ts:87–107  ·  view source on GitHub ↗
(rep: FastifyReply)

Source from the content-addressed store, hash-verified

85}
86
87function captureReply(rep: FastifyReply) {
88 const savedReply = {
89 // @ts-expect-error Exists
90 id: rep.__id,
91 headers: rep.getHeaders(),
92 timestamp: Date.now(),
93 // @ts-expect-error Exists
94 payload: rep.__payload,
95 statusCode: rep.statusCode
96 };
97
98 if (RESPONSE_BUFFER.length > 10) {
99 appendFileSync(
100 join(LOGS_DIRECTORY, RESPONSE_CAPTURE_FILE),
101 RESPONSE_BUFFER.map(rb => JSON.stringify(rb)).join('\n') + '\n'
102 );
103 RESPONSE_BUFFER = [savedReply];
104 } else {
105 RESPONSE_BUFFER.push(savedReply);
106 }
107}
108
109/**
110 * Returns a subset of the given object with the values or properties given removed.

Callers 1

shadowCaptureFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected