diff --git a/src/assembly-ai/assembly-ai.controller.ts b/src/assembly-ai/assembly-ai.controller.ts index a2e7020..240dd54 100644 --- a/src/assembly-ai/assembly-ai.controller.ts +++ b/src/assembly-ai/assembly-ai.controller.ts @@ -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( - (utterance) => ` -${utterance.speaker}: + utterances + .map( + (utterance) => ` +Speaker ${utterance.speaker}: ${utterance.text}`, - ), + ) + .join('\n\n'), ); } } diff --git a/src/main.ts b/src/main.ts index 92c4cb0..be6e863 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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); }