@flowselections/floriday-voorraad 1.0.82 → 1.0.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/components/voorraad/ArtikelWizard.d.ts.map +1 -1
- package/dist-lib/components/voorraad/ArtikelWizard.js +53 -10
- package/dist-lib/components/voorraad/FloridayTakeoverPanel.d.ts +7 -0
- package/dist-lib/components/voorraad/FloridayTakeoverPanel.d.ts.map +1 -0
- package/dist-lib/components/voorraad/FloridayTakeoverPanel.js +186 -0
- package/dist-lib/components/voorraad/VoorraadPage.d.ts.map +1 -1
- package/dist-lib/components/voorraad/VoorraadPage.js +2 -1
- package/dist-lib/hooks-entry.d.ts +1 -0
- package/dist-lib/hooks-entry.d.ts.map +1 -1
- package/dist-lib/hooks-entry.js +1 -0
- package/dist-lib/integrations/supabase/types.d.ts +773 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/floriday-client.d.ts +5 -0
- package/dist-lib/lib/floriday-client.d.ts.map +1 -1
- package/dist-lib/lib/floriday-client.js +59 -50
- package/dist-lib/lib/floriday-takeover.functions.d.ts +49 -0
- package/dist-lib/lib/floriday-takeover.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-takeover.functions.js +185 -0
- package/dist-lib/lib/publish-readiness.js +2 -2
- package/dist-lib/server-hooks/__tests__/trade-item-photo.test.d.ts +2 -0
- package/dist-lib/server-hooks/__tests__/trade-item-photo.test.d.ts.map +1 -0
- package/dist-lib/server-hooks/__tests__/trade-item-photo.test.js +19 -0
- package/dist-lib/server-hooks/floriday-stock-reconcile.d.ts.map +1 -1
- package/dist-lib/server-hooks/floriday-stock-reconcile.js +5 -1
- package/dist-lib/server-hooks/guard.d.ts.map +1 -1
- package/dist-lib/server-hooks/guard.js +26 -3
- package/dist-lib/server-hooks/trade-item-photo.d.ts +13 -0
- package/dist-lib/server-hooks/trade-item-photo.d.ts.map +1 -0
- package/dist-lib/server-hooks/trade-item-photo.js +354 -0
- package/package.json +10 -1
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upload-handler voor artikelfoto's (losse app én Shell via flowselections.serverRoutes).
|
|
3
|
+
* Alleen ingelogde gebruikers van deze database (sessie-bearer); de gateway-
|
|
4
|
+
* sleutel blijft server-side. Server-only.
|
|
5
|
+
*
|
|
6
|
+
* Flow (§14.11):
|
|
7
|
+
* 1. Browser POSTet multipart/form-data met `file` en optioneel `tradeItemId`.
|
|
8
|
+
* 2. Wij verifiëren de Supabase-bearer en bepalen de actieve koppeling zelf.
|
|
9
|
+
* 3. We sturen de RAW bytes door naar /api/public/gateway/media-upload —
|
|
10
|
+
* géén base64-inflatie, géén formData-rebuild. HMAC zit in
|
|
11
|
+
* gatewayMediaUpload (server-only secret).
|
|
12
|
+
*/
|
|
13
|
+
import { createClient } from "@supabase/supabase-js";
|
|
14
|
+
function json(body, status = 200) {
|
|
15
|
+
return new Response(JSON.stringify(body), {
|
|
16
|
+
status,
|
|
17
|
+
headers: { "Content-Type": "application/json" },
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function messageForReason(reason) {
|
|
21
|
+
switch (reason) {
|
|
22
|
+
case "image_too_small":
|
|
23
|
+
return "De foto is te klein. Gebruik een foto van minstens 640 × 640 pixels.";
|
|
24
|
+
case "image_too_large":
|
|
25
|
+
return "De foto is te groot. Gebruik een foto van maximaal 5 MB.";
|
|
26
|
+
case "unsupported_type":
|
|
27
|
+
return "Dit bestandstype kan niet. Gebruik een JPG- of PNG-foto.";
|
|
28
|
+
case "invalid_payload":
|
|
29
|
+
return "Floriday accepteert deze foto niet. Probeer een andere foto.";
|
|
30
|
+
case "network":
|
|
31
|
+
return "Floriday is even niet bereikbaar. Probeer het zo opnieuw.";
|
|
32
|
+
case "not_logged_in":
|
|
33
|
+
return "Je bent uitgelogd. Log opnieuw in en probeer het nog eens.";
|
|
34
|
+
case "not_connected":
|
|
35
|
+
case "config_missing":
|
|
36
|
+
return "De koppeling met Floriday werkt niet. Neem contact op met Flow Selections.";
|
|
37
|
+
default:
|
|
38
|
+
return "Foto kon niet worden geüpload. Probeer het opnieuw.";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function classifyGatewayError(status, message) {
|
|
42
|
+
const m = message.toLowerCase();
|
|
43
|
+
if (m.includes("resolution") || m.includes("640") || m.includes("too small") || m.includes("dimensions")) {
|
|
44
|
+
return "image_too_small";
|
|
45
|
+
}
|
|
46
|
+
if (m.includes("5mb") || m.includes("too large") || m.includes("size") && m.includes("exceed")) {
|
|
47
|
+
return "image_too_large";
|
|
48
|
+
}
|
|
49
|
+
if (m.includes("unsupported") || m.includes("content-type") || m.includes("media type")) {
|
|
50
|
+
return "unsupported_type";
|
|
51
|
+
}
|
|
52
|
+
if (status && status >= 500)
|
|
53
|
+
return "network";
|
|
54
|
+
if (status && status >= 400 && status < 500)
|
|
55
|
+
return "invalid_payload";
|
|
56
|
+
return "unknown";
|
|
57
|
+
}
|
|
58
|
+
function sanitizeDetail(msg) {
|
|
59
|
+
// Verwijder tokens/headers/HMAC uit de error-string voordat we het naar
|
|
60
|
+
// de browser sturen. Alleen de eerste 240 tekens zijn nuttig voor UX.
|
|
61
|
+
return msg
|
|
62
|
+
.replace(/Bearer\s+[A-Za-z0-9._-]+/gi, "Bearer ***")
|
|
63
|
+
.replace(/(x-hmac[^:]*:\s*)[A-Fa-f0-9]+/gi, "$1***")
|
|
64
|
+
.replace(/(authorization[^:]*:\s*)[^\s,]+/gi, "$1***")
|
|
65
|
+
.slice(0, 240);
|
|
66
|
+
}
|
|
67
|
+
function uploadFailed(reason, extra = {}) {
|
|
68
|
+
// Bewust géén HTTP 502/5xx naar de browser: Lovable preview toont zulke
|
|
69
|
+
// route-responses als runtime error/blank screen. De client krijgt een
|
|
70
|
+
// typed failure terug en beslist zelf over retry + vriendelijke melding.
|
|
71
|
+
const retryable = reason === "network" || reason === "unknown";
|
|
72
|
+
return json({
|
|
73
|
+
ok: false,
|
|
74
|
+
error: "upload-mislukt",
|
|
75
|
+
reason,
|
|
76
|
+
message: messageForReason(reason),
|
|
77
|
+
retryable,
|
|
78
|
+
...extra,
|
|
79
|
+
}, 200);
|
|
80
|
+
}
|
|
81
|
+
/** Herkent jpg/png aan de eerste bytes (niet aan bestandsnaam of browsertype). */
|
|
82
|
+
function sniffType(b) {
|
|
83
|
+
if (b.length >= 3 && b[0] === 0xff && b[1] === 0xd8 && b[2] === 0xff)
|
|
84
|
+
return "image/jpeg";
|
|
85
|
+
if (b.length >= 8 && b[0] === 0x89 && b[1] === 0x50 && b[2] === 0x4e && b[3] === 0x47)
|
|
86
|
+
return "image/png";
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
/** Breedte/hoogte uit PNG-IHDR of JPEG-SOF-marker. */
|
|
90
|
+
export function imageSize(b) {
|
|
91
|
+
const t = sniffType(b);
|
|
92
|
+
if (t === "image/png" && b.length >= 24) {
|
|
93
|
+
const dv = new DataView(b.buffer, b.byteOffset, b.byteLength);
|
|
94
|
+
return { w: dv.getUint32(16), h: dv.getUint32(20) };
|
|
95
|
+
}
|
|
96
|
+
if (t === "image/jpeg") {
|
|
97
|
+
let i = 2;
|
|
98
|
+
while (i + 9 < b.length) {
|
|
99
|
+
if (b[i] !== 0xff) {
|
|
100
|
+
i++;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const m = b[i + 1];
|
|
104
|
+
const len = (b[i + 2] << 8) | b[i + 3];
|
|
105
|
+
if (m >= 0xc0 && m <= 0xcf && m !== 0xc4 && m !== 0xc8 && m !== 0xcc) {
|
|
106
|
+
return { h: (b[i + 5] << 8) | b[i + 6], w: (b[i + 7] << 8) | b[i + 8] };
|
|
107
|
+
}
|
|
108
|
+
i += 2 + len;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
const MAX_BYTES = 5 * 1024 * 1024;
|
|
114
|
+
const MIN_SIDE = 640;
|
|
115
|
+
export function checkImage(head, size) {
|
|
116
|
+
if (!sniffType(head))
|
|
117
|
+
return { reason: "unsupported_type", detail: "geen jpg/png-handtekening" };
|
|
118
|
+
if (size > MAX_BYTES)
|
|
119
|
+
return { reason: "image_too_large", detail: `${size} bytes > ${MAX_BYTES}` };
|
|
120
|
+
const dim = imageSize(head);
|
|
121
|
+
if (!dim)
|
|
122
|
+
return { reason: "invalid_payload", detail: "afmeting niet leesbaar" };
|
|
123
|
+
if (dim.w < MIN_SIDE || dim.h < MIN_SIDE) {
|
|
124
|
+
return { reason: "image_too_small", detail: `${dim.w}x${dim.h} < ${MIN_SIDE}x${MIN_SIDE}` };
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
function plainFail(reason, status, detail) {
|
|
129
|
+
return json({ ok: false, reason, message: messageForReason(reason), detail }, status);
|
|
130
|
+
}
|
|
131
|
+
export async function handleTradeItemPhoto(request) {
|
|
132
|
+
if (request.method === "OPTIONS")
|
|
133
|
+
return new Response(null, { status: 204 });
|
|
134
|
+
if (request.method !== "POST")
|
|
135
|
+
return json({ error: "Method not allowed" }, 405);
|
|
136
|
+
try {
|
|
137
|
+
const SUPABASE_URL = process.env.SUPABASE_URL;
|
|
138
|
+
const SUPABASE_PUBLISHABLE_KEY = process.env.SUPABASE_PUBLISHABLE_KEY;
|
|
139
|
+
if (!SUPABASE_URL || !SUPABASE_PUBLISHABLE_KEY) {
|
|
140
|
+
return plainFail("config_missing", 500, "SUPABASE_URL/SUPABASE_PUBLISHABLE_KEY ontbreekt op de server");
|
|
141
|
+
}
|
|
142
|
+
// --- 1. Bearer-validatie -------------------------------------------------
|
|
143
|
+
const authHeader = request.headers.get("authorization");
|
|
144
|
+
if (!authHeader)
|
|
145
|
+
return plainFail("not_logged_in", 401, "Unauthorized: geen bearer");
|
|
146
|
+
if (!authHeader.startsWith("Bearer "))
|
|
147
|
+
return plainFail("not_logged_in", 401, "Unauthorized: alleen Bearer-tokens");
|
|
148
|
+
const token = authHeader.slice("Bearer ".length).trim();
|
|
149
|
+
if (!token)
|
|
150
|
+
return plainFail("not_logged_in", 401, "Unauthorized: leeg token");
|
|
151
|
+
const supabase = createClient(SUPABASE_URL, SUPABASE_PUBLISHABLE_KEY, {
|
|
152
|
+
global: { headers: { Authorization: `Bearer ${token}` } },
|
|
153
|
+
auth: { storage: undefined, persistSession: false, autoRefreshToken: false },
|
|
154
|
+
});
|
|
155
|
+
const { data: claimsData, error: claimsErr } = await supabase.auth.getClaims(token);
|
|
156
|
+
if (claimsErr || !claimsData?.claims?.sub) {
|
|
157
|
+
return plainFail("not_logged_in", 401, "Unauthorized: token ongeldig");
|
|
158
|
+
}
|
|
159
|
+
// --- 2. Multipart body ---------------------------------------------------
|
|
160
|
+
let form;
|
|
161
|
+
try {
|
|
162
|
+
form = await request.formData();
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
return json({ error: "Bad request: multipart/form-data verwacht" }, 400);
|
|
166
|
+
}
|
|
167
|
+
// Oude clients kunnen nog een connectionId meesturen. Deze waarde is
|
|
168
|
+
// nooit leidend: de actieve koppeling wordt hieronder server-side
|
|
169
|
+
// bepaald. Zo kan een browser nooit een koppeling/account kiezen.
|
|
170
|
+
const clientConnectionId = String(form.get("connectionId") ?? "").trim();
|
|
171
|
+
const tradeItemId = form.get("tradeItemId")
|
|
172
|
+
? String(form.get("tradeItemId"))
|
|
173
|
+
: null;
|
|
174
|
+
const file = form.get("file");
|
|
175
|
+
if (!(file instanceof Blob))
|
|
176
|
+
return json({ error: "file ontbreekt of geen Blob" }, 400);
|
|
177
|
+
if (file.size === 0)
|
|
178
|
+
return json({ error: "Leeg bestand" }, 400);
|
|
179
|
+
const filename = file.name ||
|
|
180
|
+
`photo-${Date.now()}.${(file.type || "image/jpeg").split("/")[1] ?? "jpg"}`;
|
|
181
|
+
const headBytes = new Uint8Array(await file.slice(0, 256 * 1024).arrayBuffer());
|
|
182
|
+
const check = checkImage(headBytes, file.size);
|
|
183
|
+
if (check)
|
|
184
|
+
return uploadFailed(check.reason, { detail: check.detail });
|
|
185
|
+
const contentType = sniffType(headBytes) ?? "image/jpeg";
|
|
186
|
+
// --- 3. Actieve koppeling + omgeving via de gedeelde bron ---------------
|
|
187
|
+
let environment;
|
|
188
|
+
try {
|
|
189
|
+
const { checkFloridayReadiness } = await import("../lib/floriday-readiness.server.js");
|
|
190
|
+
const readiness = await checkFloridayReadiness(supabase);
|
|
191
|
+
if (!readiness.ready || !readiness.connectionId || !readiness.environment) {
|
|
192
|
+
return plainFail("not_connected", 409, `FLORIDAY_NOT_READY: ${readiness.message}`);
|
|
193
|
+
}
|
|
194
|
+
if (clientConnectionId && readiness.connectionId !== clientConnectionId) {
|
|
195
|
+
return json({
|
|
196
|
+
error: "De verbinding is gewijzigd. Vernieuw de pagina en probeer opnieuw.",
|
|
197
|
+
}, 409);
|
|
198
|
+
}
|
|
199
|
+
environment = readiness.environment;
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
const { FloridayEnvError } = await import("../lib/floriday-env.js");
|
|
203
|
+
if (e instanceof FloridayEnvError) {
|
|
204
|
+
return plainFail("not_connected", 400, `${e.code}: ${e.message}`);
|
|
205
|
+
}
|
|
206
|
+
throw e;
|
|
207
|
+
}
|
|
208
|
+
// --- 4. Raw bytes doorsturen naar de centrale gateway -------------------
|
|
209
|
+
const buf = new Uint8Array(await file.arrayBuffer());
|
|
210
|
+
const hashBuf = await crypto.subtle.digest("SHA-256", buf);
|
|
211
|
+
const hashHex = Array.from(new Uint8Array(hashBuf))
|
|
212
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
213
|
+
.join("");
|
|
214
|
+
const idempotencyKey = `inventory:image:${tradeItemId ?? "anon"}:${hashHex.slice(0, 16)}`;
|
|
215
|
+
// Floriday Suppliers API 2026v1: POST /media (operatie AddImage),
|
|
216
|
+
// multipart/form-data met verplicht form-veld "image".
|
|
217
|
+
// LET OP: de gateway plakt het pad achter https://api.[staging.]floriday.io
|
|
218
|
+
// ZONDER versie-prefix — die moet dus in het pad zelf zitten.
|
|
219
|
+
const path = "/suppliers-api-2026v1/media";
|
|
220
|
+
const requestTimestamp = Date.now();
|
|
221
|
+
const clientUserId = claimsData.claims.sub;
|
|
222
|
+
const reportFailure = async (info) => {
|
|
223
|
+
// (a) push naar Auth-module diagnostics-endpoint
|
|
224
|
+
try {
|
|
225
|
+
const { reportGatewayFailure } = await import("../lib/floriday-gateway.server.js");
|
|
226
|
+
await reportGatewayFailure({
|
|
227
|
+
module: "inventory",
|
|
228
|
+
action: "media-upload",
|
|
229
|
+
environment,
|
|
230
|
+
path,
|
|
231
|
+
referenceId: tradeItemId ?? null,
|
|
232
|
+
idempotencyKey,
|
|
233
|
+
attemptNumber: info.attemptNumber,
|
|
234
|
+
requestTimestamp,
|
|
235
|
+
requestBodyHash: hashHex,
|
|
236
|
+
fileMeta: {
|
|
237
|
+
filename,
|
|
238
|
+
contentType,
|
|
239
|
+
sizeBytes: buf.byteLength,
|
|
240
|
+
},
|
|
241
|
+
responseStatus: info.responseStatus ?? null,
|
|
242
|
+
responseContentType: info.responseContentType ?? null,
|
|
243
|
+
responseSnippet: info.responseSnippet?.slice(0, 500) ?? null,
|
|
244
|
+
errorMessage: info.errorMessage,
|
|
245
|
+
clientUserId,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
catch (e) {
|
|
249
|
+
console.warn("[trade-item-photo] reportGatewayFailure faalde", e);
|
|
250
|
+
}
|
|
251
|
+
// (b) eigen audit-tabel (zonder snippet)
|
|
252
|
+
try {
|
|
253
|
+
const { getAdminClient } = await import("../lib/supabase-admin.server.js");
|
|
254
|
+
const supabaseAdmin = getAdminClient();
|
|
255
|
+
const { error: insErr } = await supabaseAdmin
|
|
256
|
+
.from("voorraad_media_upload_failures")
|
|
257
|
+
.insert({
|
|
258
|
+
environment,
|
|
259
|
+
path,
|
|
260
|
+
reference_id: tradeItemId ?? null,
|
|
261
|
+
idempotency_key: idempotencyKey,
|
|
262
|
+
attempt_number: info.attemptNumber,
|
|
263
|
+
request_timestamp: requestTimestamp,
|
|
264
|
+
request_body_hash: hashHex,
|
|
265
|
+
filename,
|
|
266
|
+
content_type: contentType,
|
|
267
|
+
size_bytes: buf.byteLength,
|
|
268
|
+
response_status: info.responseStatus ?? null,
|
|
269
|
+
response_content_type: info.responseContentType ?? null,
|
|
270
|
+
error_message: info.errorMessage,
|
|
271
|
+
client_user_id: clientUserId,
|
|
272
|
+
});
|
|
273
|
+
if (insErr) {
|
|
274
|
+
console.error("[trade-item-photo] audit-insert error", insErr.message, insErr.details);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
catch (e) {
|
|
278
|
+
console.warn("[trade-item-photo] audit-insert faalde", e);
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
try {
|
|
282
|
+
const { gatewayMediaUpload } = await import("../lib/floriday-gateway.server.js");
|
|
283
|
+
const res = await gatewayMediaUpload({
|
|
284
|
+
caller: "voorraad",
|
|
285
|
+
environment: environment,
|
|
286
|
+
path,
|
|
287
|
+
method: "POST",
|
|
288
|
+
filename,
|
|
289
|
+
contentType,
|
|
290
|
+
bytes: buf,
|
|
291
|
+
formField: "image", // Floriday POST /media vereist form-veld "image"
|
|
292
|
+
referenceId: tradeItemId ?? undefined,
|
|
293
|
+
idempotencyKey,
|
|
294
|
+
});
|
|
295
|
+
// Floriday 2026v1 levert { mediaId: "<uuid>" } terug op POST /media.
|
|
296
|
+
const mediaId = (res.data &&
|
|
297
|
+
(res.data.mediaId ||
|
|
298
|
+
res.data.imageId ||
|
|
299
|
+
res.data.id)) ||
|
|
300
|
+
null;
|
|
301
|
+
const host = environment === "live"
|
|
302
|
+
? "https://image.floriday.io"
|
|
303
|
+
: "https://image.staging.floriday.io";
|
|
304
|
+
// Docs: https://image.[staging.]floriday.io/{mediaId}.{ext}
|
|
305
|
+
const ext = contentType === "image/png" ? "png" : "jpg";
|
|
306
|
+
const url = mediaId
|
|
307
|
+
? `${host}/${mediaId}.${ext}`
|
|
308
|
+
: (res.data && (res.data.url || res.data.imageUrl)) || null;
|
|
309
|
+
if (!mediaId || !url) {
|
|
310
|
+
const snippet = JSON.stringify(res.data ?? {}).slice(0, 500);
|
|
311
|
+
console.error("[trade-item-photo] geen mediaId", { status: res.status, snippet, filename, contentType, size: buf.byteLength });
|
|
312
|
+
await reportFailure({
|
|
313
|
+
attemptNumber: 1,
|
|
314
|
+
responseStatus: res.status ?? null,
|
|
315
|
+
responseContentType: "application/json",
|
|
316
|
+
responseSnippet: snippet,
|
|
317
|
+
errorMessage: "Gateway leverde geen mediaId terug",
|
|
318
|
+
});
|
|
319
|
+
return uploadFailed("invalid_payload", {
|
|
320
|
+
attemptId: res.attemptId ?? null,
|
|
321
|
+
gatewayStatus: res.status ?? null,
|
|
322
|
+
detail: sanitizeDetail(snippet),
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
return json({ ok: true, url, imageId: mediaId, mediaId, attemptId: res.attemptId });
|
|
326
|
+
}
|
|
327
|
+
catch (e) {
|
|
328
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
329
|
+
// Probeer status/content-type uit de error-tekst te halen (gateway
|
|
330
|
+
// gooit messages als "gateway media-upload → niet-JSON antwoord
|
|
331
|
+
// (status=502)").
|
|
332
|
+
const statusMatch = /status=(\d{3})/.exec(msg);
|
|
333
|
+
const responseStatus = statusMatch ? Number(statusMatch[1]) : null;
|
|
334
|
+
const reason = classifyGatewayError(responseStatus, msg);
|
|
335
|
+
console.error("[trade-item-photo] gateway-fout", { reason, responseStatus, msg, filename, contentType, size: buf.byteLength, tradeItemId });
|
|
336
|
+
await reportFailure({
|
|
337
|
+
attemptNumber: 1,
|
|
338
|
+
responseStatus,
|
|
339
|
+
responseContentType: null,
|
|
340
|
+
responseSnippet: msg.slice(0, 500),
|
|
341
|
+
errorMessage: msg,
|
|
342
|
+
});
|
|
343
|
+
return uploadFailed(reason, {
|
|
344
|
+
gatewayStatus: responseStatus,
|
|
345
|
+
detail: sanitizeDetail(msg),
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
catch (outer) {
|
|
350
|
+
const msg = outer instanceof Error ? outer.message : String(outer);
|
|
351
|
+
console.error("[trade-item-photo] unhandled", msg, outer?.stack);
|
|
352
|
+
return plainFail("unknown", 500, sanitizeDetail(`Interne fout: ${msg}`));
|
|
353
|
+
}
|
|
354
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowselections/floriday-voorraad",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.86",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist-lib/index.js",
|
|
@@ -158,6 +158,15 @@
|
|
|
158
158
|
"POST",
|
|
159
159
|
"OPTIONS"
|
|
160
160
|
]
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"routePath": "/api/trade-item-photo",
|
|
164
|
+
"import": "@flowselections/floriday-voorraad/hooks",
|
|
165
|
+
"handler": "handleTradeItemPhoto",
|
|
166
|
+
"methods": [
|
|
167
|
+
"POST",
|
|
168
|
+
"OPTIONS"
|
|
169
|
+
]
|
|
161
170
|
}
|
|
162
171
|
]
|
|
163
172
|
}
|