import { ConflictException, Controller, HttpCode, HttpStatus, Post } from '@nestjs/common'; import { HiboutikService } from './services/hiboutik/hiboutik.service'; @Controller() export class AppController { constructor(private readonly hiboutikService: HiboutikService) {} /** Starts the synchronization in the background and answers immediately: 202, or 409 if one is already running. */ @Post('sync') @HttpCode(HttpStatus.ACCEPTED) hiboutikSync() { if (!this.hiboutikService.startSync()) { throw new ConflictException('A Hiboutik synchronization is already in progress'); } return { message: 'Hiboutik synchronization started' }; } }