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

Function captureRequest

api/src/plugins/shadow-capture.ts:63–85  ·  view source on GitHub ↗
(req: FastifyRequest)

Source from the content-addressed store, hash-verified

61
62/* eslint-disable @typescript-eslint/no-unsafe-assignment */
63function captureRequest(req: FastifyRequest) {
64 const savedRequest = {
65 // @ts-expect-error Exists
66 id: req.__id,
67 // @ts-expect-error Exists
68 timestamp: req.__timestamp,
69 url: req.url,
70 headers: omit(req.headers, 'cookie'),
71 cookies: include(req.cookies, '_csrf', 'csrf_token', 'jwt_access_token'),
72 user: req.user,
73 body: req.body
74 };
75
76 if (REQUEST_BUFFER.length > 10) {
77 appendFileSync(
78 join(LOGS_DIRECTORY, REQUEST_CAPTURE_FILE),
79 REQUEST_BUFFER.map(rb => JSON.stringify(rb)).join('\n') + '\n'
80 );
81 REQUEST_BUFFER = [savedRequest];
82 } else {
83 REQUEST_BUFFER.push(savedRequest);
84 }
85}
86
87function captureReply(rep: FastifyReply) {
88 const savedReply = {

Callers 1

shadowCaptureFunction · 0.85

Calls 2

omitFunction · 0.85
includeFunction · 0.85

Tested by

no test coverage detected