2021-08-14 16:55:40 +02:00
|
|
|
import { CacheService } from '@ghostfolio/api/app/cache/cache.service';
|
|
|
|
import { RedisCacheService } from '@ghostfolio/api/app/redis-cache/redis-cache.service';
|
2021-09-11 09:27:22 +02:00
|
|
|
import type { 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';
|
|
|
|
|
|
|
|
@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
|
|
|
}
|
|
|
|
}
|