Set response headers
This commit is contained in:
@@ -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(
|
||||
return res.header('Content-Type', 'text/plain; charset=utf-8').send(
|
||||
utterances.map(
|
||||
(utterance) => `
|
||||
${utterance.speaker}:
|
||||
${utterance.text}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user