lab4: e2e вложений, отказы S3/PG, исправления потока загрузки
This commit is contained in:
+12
-10
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user