feat(server): ✨ add body length tracking middleware
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
bbf86b31c5
commit
e496834530
1 changed files with 12 additions and 0 deletions
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue