Allow larger body sizes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Body, Controller, Post, Res } from '@nestjs/common';
|
||||
import { ApiResponse } from '@nestjs/swagger';
|
||||
import { ApiBody, ApiConsumes, ApiResponse } from '@nestjs/swagger';
|
||||
import { Response } from 'express';
|
||||
|
||||
interface Utterance {
|
||||
@@ -25,17 +25,25 @@ export class AssemblyAiController {
|
||||
description: 'Converts utterances to a script format',
|
||||
type: String,
|
||||
})
|
||||
@ApiBody({
|
||||
description: 'Array of utterances or an object containing utterances',
|
||||
type: String,
|
||||
})
|
||||
// @ApiConsumes('text/plain')
|
||||
async utteranceToScript(
|
||||
@Body() body: { utterances: Utterance[] } | Utterance[],
|
||||
@Res() res: Response,
|
||||
) {
|
||||
// body = JSON.parse(body as unknown as string);
|
||||
const utterances = Array.isArray(body) ? body : body.utterances;
|
||||
return res.header('Content-Type', 'text/plain; charset=utf-8').send(
|
||||
utterances.map(
|
||||
utterances
|
||||
.map(
|
||||
(utterance) => `
|
||||
${utterance.speaker}:
|
||||
Speaker ${utterance.speaker}:
|
||||
${utterance.text}`,
|
||||
),
|
||||
)
|
||||
.join('\n\n'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -18,7 +18,8 @@ async function bootstrap() {
|
||||
const document = SwaggerModule.createDocument(app, config);
|
||||
SwaggerModule.setup('api', app, document);
|
||||
app.enableCors({ origin: '*' });
|
||||
app.useBodyParser('text');
|
||||
app.useBodyParser('json', { limit: '50mb' });
|
||||
app.useBodyParser('text', { limit: '50mb' });
|
||||
app.disable('x-powered-by');
|
||||
await app.listen(3000);
|
||||
}
|
||||
|
Reference in New Issue
Block a user