mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Merge pull request #335 from R0m1k3/1.1
Update webhook integration to use JSON instead of form-data
This commit is contained in:
5 files changed
+18
-33
No files matched your search
@@ -37,4 +37,4 @@ args = "npm run dev"
|
||||
waitForPort = 5000
|
||||
|
||||
[agent]
|
||||
integrations = ["javascript_object_storage==1.0.0", "javascript_database==1.0.0", "javascript_log_in_with_replit==1.0.0"]
|
||||
integrations = ["javascript_log_in_with_replit==1.0.0", "javascript_object_storage==1.0.0", "javascript_database==1.0.0"]
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 178 KiB |
Generated
-11
@@ -41,7 +41,6 @@
|
||||
"@radix-ui/react-tooltip": "^1.2.0",
|
||||
"@tanstack/react-query": "^5.60.5",
|
||||
"@types/bcrypt": "^6.0.0",
|
||||
"@types/form-data": "^2.2.1",
|
||||
"@types/memoizee": "^0.4.12",
|
||||
"@types/node-fetch": "^2.6.13",
|
||||
"@types/pg": "^8.15.4",
|
||||
@@ -59,7 +58,6 @@
|
||||
"express": "^4.21.2",
|
||||
"express-rate-limit": "^7.5.1",
|
||||
"express-session": "^1.18.1",
|
||||
"form-data": "^4.0.4",
|
||||
"framer-motion": "^11.13.1",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"input-otp": "^1.4.2",
|
||||
@@ -3751,15 +3749,6 @@
|
||||
"@types/express": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/form-data": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz",
|
||||
"integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/http-errors": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.5.tgz",
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
"@radix-ui/react-tooltip": "^1.2.0",
|
||||
"@tanstack/react-query": "^5.60.5",
|
||||
"@types/bcrypt": "^6.0.0",
|
||||
"@types/form-data": "^2.2.1",
|
||||
"@types/memoizee": "^0.4.12",
|
||||
"@types/node-fetch": "^2.6.13",
|
||||
"@types/pg": "^8.15.4",
|
||||
@@ -61,7 +60,6 @@
|
||||
"express": "^4.21.2",
|
||||
"express-rate-limit": "^7.5.1",
|
||||
"express-session": "^1.18.1",
|
||||
"form-data": "^4.0.4",
|
||||
"framer-motion": "^11.13.1",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"input-otp": "^1.4.2",
|
||||
|
||||
+17
-19
@@ -128,24 +128,20 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
userId: user.id
|
||||
});
|
||||
|
||||
// Créer FormData pour l'envoi vers n8n
|
||||
let FormData;
|
||||
try {
|
||||
FormData = (await import('form-data')).default;
|
||||
console.log('✅ BAP: form-data imported successfully');
|
||||
} catch (error) {
|
||||
console.error('❌ BAP: Erreur import form-data:', error);
|
||||
return res.status(500).json({ error: 'Erreur configuration serveur (form-data)' });
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('pdf', fileBuffer, {
|
||||
filename: fileName,
|
||||
// Préparer les données JSON pour le webhook n8n (sans form-data)
|
||||
const webhookPayload = {
|
||||
recipient: recipient,
|
||||
fileName: fileName,
|
||||
fileSize: fileBuffer.length,
|
||||
pdfBase64: pdfBase64, // On renvoie le base64 directement
|
||||
contentType: 'application/pdf'
|
||||
};
|
||||
|
||||
console.log('✅ BAP: Payload JSON préparé', {
|
||||
recipient,
|
||||
fileName,
|
||||
fileSize: fileBuffer.length
|
||||
});
|
||||
formData.append('recipient', recipient);
|
||||
|
||||
console.log('✅ BAP: FormData créé avec succès');
|
||||
|
||||
// Envoyer vers le webhook n8n
|
||||
const webhookUrl = 'https://workflow.ffnancy.fr/webhook/a3d03176-b72f-412d-8fb9-f920b9fbab4d';
|
||||
@@ -157,9 +153,11 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
|
||||
const response = await fetch(webhookUrl, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
signal: controller.signal,
|
||||
headers: formData.getHeaders()
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(webhookPayload),
|
||||
signal: controller.signal
|
||||
});
|
||||
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
Reference in new issue
Block a user