fix: proxy ranking avatars through backend

This commit is contained in:
2026-08-02 01:00:14 +08:00
parent f37136d8c3
commit 2a3125075f
2 changed files with 74 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
import { Controller, Get, Query } from '@nestjs/common';
import { Controller, Get, Header, Param, Query, Res } from '@nestjs/common';
import { ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
import { Response } from 'express';
import { RankingsService } from './rankings.service';
import { RankingCategoryId } from './rankings.types';
@@ -8,6 +9,17 @@ import { RankingCategoryId } from './rankings.types';
export class RankingsController {
constructor(private readonly rankingsService: RankingsService) {}
@Get('datawhale-honor/avatar/:memberId')
@Header('Cache-Control', 'public, max-age=86400, stale-while-revalidate=604800')
@ApiOperation({ summary: '代理 Datawhale 荣誉榜成员头像' })
async getDatawhaleMemberAvatar(
@Param('memberId') memberId: string,
@Res() res: Response,
): Promise<void> {
const avatar = await this.rankingsService.getMemberAvatar(memberId);
res.type(avatar.contentType).send(avatar.body);
}
@Get('datawhale-honor')
@ApiOperation({
summary: '获取Datawhale荣誉榜',