feat(server): add body length tracking middleware

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Natalie 2026-05-18 00:06:04 -07:00
parent bbf86b31c5
commit e496834530

View file

@ -94,6 +94,18 @@ export async function createApp() {
const app = new Hono()
.onError(errorHandler)
.use('*', async (c, next) => {
const ct = c.req.header('content-length');
const te = c.req.header('transfer-encoding');
if (ct || te) {
const method = c.req.method;
const path = c.req.path;
if (method !== 'GET') {
console.log(JSON.stringify({ ts: new Date().toISOString(), msg: 'pre_bodylimit', method, path, contentLength: ct, transferEncoding: te }));
}
}
await next();
})
.use('*', bodyLimit({ maxSize: 100 * 1024 * 1024 })) // 100MB for large iMessage batch uploads
.get('/health', (c) => c.json({ ok: true }))
.get('/health/deep', async (c) => {