forked from xiangwang25/whale-town-end-v2
fix: proxy ranking avatars through backend
This commit is contained in:
@@ -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荣誉榜',
|
||||
|
||||
Reference in New Issue
Block a user