2021-05-16 22:11:14 +02:00
|
|
|
import { RequestWithUser } from '@ghostfolio/common/types';
|
2021-05-16 21:20:59 +02:00
|
|
|
import { Controller, Inject, Post, UseGuards } from '@nestjs/common';
|
2021-04-13 21:53:58 +02:00
|
|
|
import { REQUEST } from '@nestjs/core';
|
|
|
|
import { AuthGuard } from '@nestjs/passport';
|
|
|
|
|
|
|
|
import { RedisCacheService } from '../redis-cache/redis-cache.service';
|
|
|
|
import { CacheService } from './cache.service';
|
|
|
|
|
|
|
|
@Controller('cache')
|
|
|
|
export class CacheController {
|
|
|
|
public constructor(
|
|
|
|
private readonly cacheService: CacheService,
|
|
|
|
private readonly redisCacheService: RedisCacheService,
|
|
|
|
@Inject(REQUEST) private readonly request: RequestWithUser
|
|
|
|
) {
|
|
|
|
this.redisCacheService.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Post('flush')
|
|
|
|
@UseGuards(AuthGuard('jwt'))
|
|
|
|
public async flushCache(): Promise<void> {
|
|
|
|
this.redisCacheService.reset();
|
|
|
|
|
2021-08-07 20:52:55 +02:00
|
|
|
return this.cacheService.flush();
|
2021-04-13 21:53:58 +02:00
|
|
|
}
|
|
|
|
}
|