diff --git a/src/rices/rices.controller.ts b/src/rices/rices.controller.ts index 6a5ef82..b16afd0 100644 --- a/src/rices/rices.controller.ts +++ b/src/rices/rices.controller.ts @@ -11,9 +11,10 @@ import { HttpStatus, UnauthorizedException, BadRequestException, + Res, } from '@nestjs/common'; +import { Response } from 'express'; import { RicesService } from './rices.service'; - import { ApiTags, ApiOperation, ApiResponse, ApiHeader } from '@nestjs/swagger'; @ApiTags('rices') @@ -53,17 +54,36 @@ export class RicesController { } @ApiOperation({ summary: 'Get information about a Rice' }) - @ApiResponse({ status: 200, description: 'Returns metadata of the Rice.' }) + @ApiResponse({ + status: 200, + description: 'Returns metadata of the Rice as HTML.', + }) @Get(':slug') - /************* ✨ Codeium Command ⭐ *************/ - /** - * Retrieve metadata of a rice with the given slug. - * @param slug Slug of the rice. - * @returns Metadata of the rice if found, otherwise throws a NotFoundException. - */ - /****** c6f70808-e78d-4b17-a285-d2fd79527659 *******/ - async getRice(@Param('slug') slug: string) { - return this.ricesService.findOne(slug); + async getRice(@Param('slug') slug: string, @Res() res: Response) { + const riceMetadata = await this.ricesService.findOne(slug); + + const htmlContent = ` + + + + + + ZenRice download ${slug} + + + + + +`; + + res.setHeader('Content-Type', 'text/html'); + res.send(htmlContent); } @ApiOperation({ summary: 'Update an existing Rice' }) diff --git a/test/restclient/02_download_rice.http b/test/restclient/02_download_rice.http index eb767dc..1517c6c 100644 --- a/test/restclient/02_download_rice.http +++ b/test/restclient/02_download_rice.http @@ -1,5 +1,5 @@ @baseUrl = http://localhost:3000 -@previous_slug = cool-zenrice-test-base64211-5f874c8c-71f7-4b45-830a-aa86c9328455 +@previous_slug = cool-zenrice-test-base-0ae004db-fdca-4df6-8833-1104ac1662f6 GET {{baseUrl}}/rices/{{previous_slug}} \ No newline at end of file