Skip to content

Commit 1a74b50

Browse files
authored
chore: add usage logs (#26)
1 parent a2980ee commit 1a74b50

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/proxy.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,17 @@ async function fetchAndRespond(
244244
return
245245
}
246246

247+
if (method === 'POST' && (path === '/bytes' || path === '/bzz') && response.status >= 200 && response.status < 300) {
248+
try {
249+
const json = JSON.parse(Buffer.from(response.data).toString('utf8'))
250+
if (json.reference) {
251+
logger.info('upload', { path, reference: json.reference })
252+
}
253+
} catch {
254+
// response is not JSON
255+
}
256+
}
257+
247258
delete response.headers['content-length']
248259
delete response.headers['content-encoding']
249260
delete response.headers['transfer-encoding']

0 commit comments

Comments
 (0)