Skip to content

Commit

Permalink
update api sync endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
michavie committed Jan 9, 2024
1 parent a830708 commit 1e73517
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
23 changes: 3 additions & 20 deletions apps/api/src/endpoints/apps/apps.controller.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { ApiResponse } from '@nestjs/swagger'
import { AppValue } from './entities/app.value'
import { AppService, DelegationService } from '@mvx-monorepo/common'
import { AppService } from '@mvx-monorepo/common'
import { Controller, Get, NotFoundException, Param } from '@nestjs/common'

@Controller()
export class AppsController {
constructor(
private readonly appService: AppService,
private readonly delegationService: DelegationService
) {}
constructor(private readonly appService: AppService) {}

// TODO: @UseGuards(NativeAuthGuard)
@Get('/apps')
Expand All @@ -35,23 +32,9 @@ export class AppsController {
}

// TODO: @UseGuards(NativeAuthGuard)
@Get('/apps/sync')
@Get('/sync-apps')
@ApiResponse({ status: 200 })
async syncAll() {
await this.appService.syncApps()
}

// TODO: @UseGuards(NativeAuthGuard)
@Get('/apps/:appid/sync')
@ApiResponse({ status: 200 })
@ApiResponse({ status: 404 })
async sync(@Param('appid') appId: string) {
const app = await this.appService.getAppById(+appId)

if (!app) {
throw new NotFoundException('App not found')
}

await this.delegationService.syncDelegations(app)
}
}
14 changes: 14 additions & 0 deletions apps/api/src/endpoints/collections/collections.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,18 @@ export class CollectionsController {

return values
}

// TODO: @UseGuards(NativeAuthGuard)
@Get('/apps/:appid/sync-delegations')
@ApiResponse({ status: 200 })
@ApiResponse({ status: 404 })
async sync(@Param('appid') appId: string) {
const app = await this.appService.getAppById(+appId)

if (!app) {
throw new NotFoundException('App not found')
}

await this.delegationService.syncDelegations(app)
}
}

0 comments on commit 1e73517

Please sign in to comment.