Skip to content

Commit

Permalink
fix cache control
Browse files Browse the repository at this point in the history
  • Loading branch information
csuvajit committed Jun 18, 2024
1 parent ca59e8f commit 099c14f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
11 changes: 4 additions & 7 deletions apps/service-auth/src/clans/clans.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CurrentUser, JwtAuthGuard, RolesGuard } from '@app/auth';
import { Public } from '@app/auth/decorators';
import { Controller, Get, Param, Query, Res, UseGuards } from '@nestjs/common';
import { Controller, Get, Header, Param, Query, Res, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiResponse, ApiTags } from '@nestjs/swagger';
import { Response } from 'express';
import { ClansService } from './clans.service';
Expand Down Expand Up @@ -43,13 +43,10 @@ export class ClansController {

@Public()
@Get('/:clanTag/badges/:size')
@Header('Cache-Control', 'max-age=600')
@ApiResponse({ type: CWLStatsOutput, status: 200 })
async getClanBadges(
@Param('clanTag') clanTag: string,
@Param('size') size: string,
@Res() res: Response,
) {
const buffer = await this.clansService.getClanBadges(clanTag, size);
async getClanBadges(@Param('clanTag') clanTag: string, @Res() res: Response) {
const buffer = await this.clansService.getClanBadges(clanTag);
res.setHeader('Content-Type', 'image/png');
return res.send(Buffer.from(buffer));
}
Expand Down
4 changes: 2 additions & 2 deletions apps/service-auth/src/clans/clans.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ export class ClansService {
return 'lost';
}

public async getClanBadges(clanTag: string, size: string) {
public async getClanBadges(clanTag: string) {
const clan = await this.clashClientService.getClanOrThrow(clanTag);
return fetch(clan.badgeUrls[size]).then((res) => res.arrayBuffer());
return fetch(clan.badgeUrls.large).then((res) => res.arrayBuffer());
}
}

0 comments on commit 099c14f

Please sign in to comment.