mirror of https://github.com/nocodb/nocodb
Pranav C
2 years ago
2 changed files with 30 additions and 2 deletions
@ -1,7 +1,25 @@
|
||||
import { Controller } from '@nestjs/common'; |
||||
import { Controller, Delete, Get } from '@nestjs/common'; |
||||
import { Acl } from '../../middlewares/extract-project-id/extract-project-id.middleware'; |
||||
import { CachesService } from './caches.service'; |
||||
|
||||
@Controller('caches') |
||||
export class CachesController { |
||||
constructor(private readonly cachesService: CachesService) {} |
||||
|
||||
@Get('/api/v1/db/meta/cache') |
||||
@Acl('cacheGet') |
||||
async cacheGet(_, res) { |
||||
const data = await this.cachesService.cacheGet(); |
||||
res.set({ |
||||
'Content-Type': 'application/json', |
||||
'Content-Disposition': `attachment; filename="cache-export.json"`, |
||||
}); |
||||
return JSON.stringify(data); |
||||
} |
||||
|
||||
@Delete('/api/v1/db/meta/cache') |
||||
@Acl('cacheDelete') |
||||
async cacheDelete() { |
||||
return await this.cachesService.cacheDelete(); |
||||
} |
||||
} |
||||
|
@ -1,4 +1,14 @@
|
||||
import { Injectable } from '@nestjs/common'; |
||||
import NocoCache from '../../cache/NocoCache'; |
||||
|
||||
@Injectable() |
||||
export class CachesService {} |
||||
export class CachesService { |
||||
async cacheGet() { |
||||
return await NocoCache.export(); |
||||
} |
||||
|
||||
async cacheDelete() { |
||||
await NocoCache.destroy(); |
||||
return true; |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue