mirror of
https://github.com/zen-browser/rices.git
synced 2025-07-07 08:55:40 +02:00
fix zenrices download method
This commit is contained in:
parent
aaee70f6df
commit
c4d83be80b
2 changed files with 32 additions and 12 deletions
|
@ -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 = `<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<script>
|
||||
const zenrice = ${riceMetadata};
|
||||
</script>
|
||||
<title>ZenRice download ${slug}</title>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
window.location.href = 'https://zen-browser.app/download';
|
||||
});
|
||||
</script>
|
||||
<!-- Body content is intentionally left blank -->
|
||||
</body>
|
||||
</html>`;
|
||||
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
res.send(htmlContent);
|
||||
}
|
||||
|
||||
@ApiOperation({ summary: 'Update an existing Rice' })
|
||||
|
|
|
@ -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}}
|
Loading…
Add table
Add a link
Reference in a new issue