project-nomad/admin/app/controllers/collection_updates_controller.ts
2026-02-11 21:49:46 -08:00

26 lines
896 B
TypeScript

import { CollectionUpdateService } from '#services/collection_update_service'
import {
applyContentUpdateValidator,
applyAllContentUpdatesValidator,
} from '#validators/common'
import type { HttpContext } from '@adonisjs/core/http'
export default class CollectionUpdatesController {
async checkForUpdates({}: HttpContext) {
const service = new CollectionUpdateService()
return await service.checkForUpdates()
}
async applyUpdate({ request }: HttpContext) {
const update = await request.validateUsing(applyContentUpdateValidator)
const service = new CollectionUpdateService()
return await service.applyUpdate(update)
}
async applyAllUpdates({ request }: HttpContext) {
const { updates } = await request.validateUsing(applyAllContentUpdatesValidator)
const service = new CollectionUpdateService()
return await service.applyAllUpdates(updates)
}
}