feat(sync): synchronize Hiboutik data through POST /sync

POST /sync starts the full synchronization in the background (202, or 409 when one is already running). Entities are synced in dependency order: brands, categories, suppliers, products (with versions and stocks), customers. Each row is synced independently so that a failure is logged without stopping the rest. Replaces the default AppService.
This commit is contained in:
MastersGame
2026-11-05 23:00:49 +01:00
parent 27d0e0149d
commit c5f65dcb62
17 changed files with 878 additions and 34 deletions

View File

@@ -1,12 +1,17 @@
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
import { ConflictException, Controller, HttpCode, HttpStatus, Post } from '@nestjs/common';
import { HiboutikService } from './services/hiboutik/hiboutik.service';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
constructor(private readonly hiboutikService: HiboutikService) {}
@Get()
getHello(): string {
return this.appService.getHello();
/** 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' };
}
}