lab4: e2e вложений, отказы S3/PG, исправления потока загрузки

This commit is contained in:
2026-10-22 22:37:05 +03:00
parent 6fcc623447
commit 7de3012b46
7 changed files with 778 additions and 12 deletions
+12 -10
View File
@@ -18,16 +18,18 @@ async function bootstrap(): Promise<void> {
);
// Raw image bodies reach the controller as an unread stream: the upload is
// bounded by our own checks, not by Fastify's bodyLimit.
app.getHttpAdapter()
.getInstance()
.addContentTypeParser(
['image/png', 'image/jpeg'],
(
_request: unknown,
payload: unknown,
done: (error: Error | null, body?: unknown) => void,
) => done(null, payload),
);
const fastify = app.getHttpAdapter().getInstance();
// Fastify's built-in text/plain parser buffers the body and fails binary
// input with 400; the upload service answers 415 for it instead.
fastify.removeContentTypeParser('text/plain');
fastify.addContentTypeParser(
['image/png', 'image/jpeg', 'text/plain'],
(
_request: unknown,
payload: unknown,
done: (error: Error | null, body?: unknown) => void,
) => done(null, payload),
);
app.useGlobalInterceptors(
new RequestIdInterceptor(
app.get(HttpAdapterHost),