mirror of
https://github.com/zen-browser/rices.git
synced 2025-07-07 17:05: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,
|
HttpStatus,
|
||||||
UnauthorizedException,
|
UnauthorizedException,
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
|
Res,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
|
import { Response } from 'express';
|
||||||
import { RicesService } from './rices.service';
|
import { RicesService } from './rices.service';
|
||||||
|
|
||||||
import { ApiTags, ApiOperation, ApiResponse, ApiHeader } from '@nestjs/swagger';
|
import { ApiTags, ApiOperation, ApiResponse, ApiHeader } from '@nestjs/swagger';
|
||||||
|
|
||||||
@ApiTags('rices')
|
@ApiTags('rices')
|
||||||
|
@ -53,17 +54,36 @@ export class RicesController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation({ summary: 'Get information about a Rice' })
|
@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')
|
@Get(':slug')
|
||||||
/************* ✨ Codeium Command ⭐ *************/
|
async getRice(@Param('slug') slug: string, @Res() res: Response) {
|
||||||
/**
|
const riceMetadata = await this.ricesService.findOne(slug);
|
||||||
* Retrieve metadata of a rice with the given slug.
|
|
||||||
* @param slug Slug of the rice.
|
const htmlContent = `<!DOCTYPE html>
|
||||||
* @returns Metadata of the rice if found, otherwise throws a NotFoundException.
|
<html lang="en">
|
||||||
*/
|
<head>
|
||||||
/****** c6f70808-e78d-4b17-a285-d2fd79527659 *******/
|
<meta charset="UTF-8">
|
||||||
async getRice(@Param('slug') slug: string) {
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
return this.ricesService.findOne(slug);
|
<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' })
|
@ApiOperation({ summary: 'Update an existing Rice' })
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
@baseUrl = http://localhost:3000
|
@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}}
|
GET {{baseUrl}}/rices/{{previous_slug}}
|
Loading…
Add table
Add a link
Reference in a new issue