mirror of https://github.com/nocodb/nocodb
Pranav C
2 years ago
6 changed files with 1213 additions and 1 deletions
@ -0,0 +1,20 @@ |
|||||||
|
import { Test, TestingModule } from '@nestjs/testing'; |
||||||
|
import { MetaDiffsController } from './meta-diffs.controller'; |
||||||
|
import { MetaDiffsService } from './meta-diffs.service'; |
||||||
|
|
||||||
|
describe('MetaDiffsController', () => { |
||||||
|
let controller: MetaDiffsController; |
||||||
|
|
||||||
|
beforeEach(async () => { |
||||||
|
const module: TestingModule = await Test.createTestingModule({ |
||||||
|
controllers: [MetaDiffsController], |
||||||
|
providers: [MetaDiffsService], |
||||||
|
}).compile(); |
||||||
|
|
||||||
|
controller = module.get<MetaDiffsController>(MetaDiffsController); |
||||||
|
}); |
||||||
|
|
||||||
|
it('should be defined', () => { |
||||||
|
expect(controller).toBeDefined(); |
||||||
|
}); |
||||||
|
}); |
@ -0,0 +1,51 @@ |
|||||||
|
import { Controller, Get, Param, Post, UseGuards } from '@nestjs/common'; |
||||||
|
import { |
||||||
|
Acl, |
||||||
|
ExtractProjectIdMiddleware, |
||||||
|
} from '../../middlewares/extract-project-id/extract-project-id.middleware'; |
||||||
|
import { MetaDiffsService } from './meta-diffs.service'; |
||||||
|
import { AuthGuard } from '@nestjs/passport'; |
||||||
|
|
||||||
|
@Controller('meta-diffs') |
||||||
|
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt')) |
||||||
|
export class MetaDiffsController { |
||||||
|
constructor(private readonly metaDiffsService: MetaDiffsService) {} |
||||||
|
|
||||||
|
@Get('/api/v1/db/meta/projects/:projectId/meta-diff') |
||||||
|
@Acl('metaDiff') |
||||||
|
async metaDiff(@Param('projectId') projectId: string) { |
||||||
|
return await this.metaDiffsService.metaDiff({ projectId }); |
||||||
|
} |
||||||
|
|
||||||
|
@Get('/api/v1/db/meta/projects/:projectId/meta-diff/:baseId') |
||||||
|
async baseMetaDiff( |
||||||
|
@Param('projectId') projectId: string, |
||||||
|
@Param('baseId') baseId: string, |
||||||
|
) { |
||||||
|
return await this.metaDiffsService.baseMetaDiff({ |
||||||
|
baseId, |
||||||
|
projectId, |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
@Post('/api/v1/db/meta/projects/:projectId/meta-diff') |
||||||
|
@Acl('metaDiffSync') |
||||||
|
async metaDiffSync(@Param('projectId') projectId: string) { |
||||||
|
await this.metaDiffsService.metaDiffSync({ projectId }); |
||||||
|
return { msg: 'The meta has been synchronized successfully' }; |
||||||
|
} |
||||||
|
|
||||||
|
@Post('/api/v1/db/meta/projects/:projectId/meta-diff/:baseId') |
||||||
|
@Acl('baseMetaDiffSync') |
||||||
|
async baseMetaDiffSync( |
||||||
|
@Param('projectId') projectId: string, |
||||||
|
@Param('baseId') baseId: string, |
||||||
|
) { |
||||||
|
await this.metaDiffsService.baseMetaDiffSync({ |
||||||
|
projectId, |
||||||
|
baseId, |
||||||
|
}); |
||||||
|
|
||||||
|
return { msg: 'The base meta has been synchronized successfully' }; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,9 @@ |
|||||||
|
import { Module } from '@nestjs/common'; |
||||||
|
import { MetaDiffsService } from './meta-diffs.service'; |
||||||
|
import { MetaDiffsController } from './meta-diffs.controller'; |
||||||
|
|
||||||
|
@Module({ |
||||||
|
controllers: [MetaDiffsController], |
||||||
|
providers: [MetaDiffsService] |
||||||
|
}) |
||||||
|
export class MetaDiffsModule {} |
@ -0,0 +1,18 @@ |
|||||||
|
import { Test, TestingModule } from '@nestjs/testing'; |
||||||
|
import { MetaDiffsService } from './meta-diffs.service'; |
||||||
|
|
||||||
|
describe('MetaDiffsService', () => { |
||||||
|
let service: MetaDiffsService; |
||||||
|
|
||||||
|
beforeEach(async () => { |
||||||
|
const module: TestingModule = await Test.createTestingModule({ |
||||||
|
providers: [MetaDiffsService], |
||||||
|
}).compile(); |
||||||
|
|
||||||
|
service = module.get<MetaDiffsService>(MetaDiffsService); |
||||||
|
}); |
||||||
|
|
||||||
|
it('should be defined', () => { |
||||||
|
expect(service).toBeDefined(); |
||||||
|
}); |
||||||
|
}); |
Loading…
Reference in new issue