From b975e01e15445dbcf0b70c99e943f1668fa86b05 Mon Sep 17 00:00:00 2001 From: z3n Date: Mon, 1 Jun 2026 09:08:57 +0000 Subject: [PATCH] =?UTF-8?q?fix(uploads):=20bundling=20AsyncAPI=20multi-fic?= =?UTF-8?q?hiers=20sans=20appel=20r=C3=A9seau?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Ajout @asyncapi/bundler@0.9.0 en dépendance locale - Remplace execFile('asyncapi bundle') par l'API programmatique - redocly bundle conservé pour OpenAPI (pas de pb réseau) Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- back/package.json | 1 + back/src/modules/uploads/uploads.controller.ts | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/back/package.json b/back/package.json index b3b7689..a48fcac 100644 --- a/back/package.json +++ b/back/package.json @@ -29,6 +29,7 @@ "class-validator": "^0.14.0", "class-transformer": "^0.5.0", "@asyncapi/cli": "6.0.0", + "@asyncapi/bundler": "0.9.0", "@asyncapi/generator": "3.0.1", "@asyncapi/html-template": "3.5.6", "@redocly/cli": "latest" diff --git a/back/src/modules/uploads/uploads.controller.ts b/back/src/modules/uploads/uploads.controller.ts index 2a6a176..c00d78b 100644 --- a/back/src/modules/uploads/uploads.controller.ts +++ b/back/src/modules/uploads/uploads.controller.ts @@ -15,6 +15,8 @@ import * as os from 'os'; import { execFile } from 'child_process'; import { promisify } from 'util'; import { randomUUID } from 'crypto'; +// eslint-disable-next-line @typescript-eslint/no-require-imports +const asyncapiBundle = require('@asyncapi/bundler'); const execFileAsync = promisify(execFile); const localBin = path.join(process.cwd(), 'node_modules', '.bin'); @@ -152,12 +154,15 @@ export class UploadsController { const mainPath = path.join(tempDir, mainFile.originalname); if (type === 'OPENAPI') { + /* redocly bundle : pas d'appel réseau, fonctionne en local */ await execFileAsync('redocly', ['bundle', mainPath, '--output', bundledPath], { shell: true, env: execEnv }); + return await fsPromises.readFile(bundledPath, 'utf-8'); } else { - await execFileAsync('asyncapi', ['bundle', mainPath, '--output', bundledPath], { shell: true, env: execEnv }); + /* @asyncapi/bundler API programmatique : aucun appel réseau */ + const bundleFn = asyncapiBundle.default ?? asyncapiBundle; + const document = await bundleFn([mainPath], { base: mainPath }); + return document.string(); } - - return await fsPromises.readFile(bundledPath, 'utf-8'); } finally { /* Nettoyage du répertoire temp même en cas d'erreur */ await fsPromises.rm(tempDir, { recursive: true, force: true }).catch(() => undefined);