Set response headers

This commit is contained in:
2025-04-24 13:25:38 -06:00
parent 149668a673
commit 84efbd295c

View File

@@ -1,5 +1,6 @@
import { Body, Controller, Post } from '@nestjs/common';
import { Body, Controller, Post, Res } from '@nestjs/common';
import { ApiResponse } from '@nestjs/swagger';
import { Response } from 'express';
interface Utterance {
speaker: string;
@@ -26,12 +27,15 @@ export class AssemblyAiController {
})
async utteranceToScript(
@Body() body: { utterances: Utterance[] } | Utterance[],
@Res() res: Response,
) {
const utterances = Array.isArray(body) ? body : body.utterances;
return utterances.map(
(utterance) => `
return res.header('Content-Type', 'text/plain; charset=utf-8').send(
utterances.map(
(utterance) => `
${utterance.speaker}:
${utterance.text}`,
),
);
}
}