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