Browse Source

feat: cache apis

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5444/head
Pranav C 2 years ago
parent
commit
884b0c84a5
  1. 20
      packages/nocodb-nest/src/modules/caches/caches.controller.ts
  2. 12
      packages/nocodb-nest/src/modules/caches/caches.service.ts

20
packages/nocodb-nest/src/modules/caches/caches.controller.ts

@ -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'; import { CachesService } from './caches.service';
@Controller('caches') @Controller('caches')
export class CachesController { export class CachesController {
constructor(private readonly cachesService: CachesService) {} 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();
}
} }

12
packages/nocodb-nest/src/modules/caches/caches.service.ts

@ -1,4 +1,14 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import NocoCache from '../../cache/NocoCache';
@Injectable() @Injectable()
export class CachesService {} export class CachesService {
async cacheGet() {
return await NocoCache.export();
}
async cacheDelete() {
await NocoCache.destroy();
return true;
}
}

Loading…
Cancel
Save