@emeryld/rrroutes-server 2.6.2 → 2.6.3
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/README.md +9 -7
- package/dist/index.cjs +28 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -20
- package/dist/index.js.map +1 -1
- package/dist/routesV3.server.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -872,28 +872,36 @@ function batchLeaf(server, path, registry, options) {
|
|
|
872
872
|
const body = req.body;
|
|
873
873
|
if (!isPlainObject2(body)) {
|
|
874
874
|
throw new Error(
|
|
875
|
-
"Batch request body must be a plain object keyed by
|
|
875
|
+
"Batch request body must be a plain object keyed by branch aliases."
|
|
876
876
|
);
|
|
877
877
|
}
|
|
878
|
-
const
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
878
|
+
const entries = Object.entries(body);
|
|
879
|
+
const outputEntries = await Promise.all(
|
|
880
|
+
entries.map(async ([alias, value]) => {
|
|
881
|
+
const payload = isPlainObject2(value) ? value : {};
|
|
882
|
+
if (typeof payload.encodedLeaf !== "string" || payload.encodedLeaf.length === 0) {
|
|
883
|
+
throw new Error(
|
|
884
|
+
`Batch entry "${alias}" must include a non-empty "encodedLeaf" string.`
|
|
885
|
+
);
|
|
886
|
+
}
|
|
887
|
+
const decodedKey = decodeURIComponent(payload.encodedLeaf);
|
|
888
|
+
const leaf = registry.byKey[decodedKey];
|
|
889
|
+
if (!leaf) {
|
|
890
|
+
throw new Error(`Unknown batch route key: ${decodedKey}`);
|
|
891
|
+
}
|
|
892
|
+
const result = await server.invoke(decodedKey, {
|
|
893
|
+
req,
|
|
894
|
+
res,
|
|
895
|
+
next,
|
|
896
|
+
params: payload.params,
|
|
897
|
+
query: payload.query,
|
|
898
|
+
body: payload.body,
|
|
899
|
+
bodyFiles: payload.bodyFiles
|
|
900
|
+
});
|
|
901
|
+
return [alias, result];
|
|
902
|
+
})
|
|
903
|
+
);
|
|
904
|
+
res.json(Object.fromEntries(outputEntries));
|
|
897
905
|
} catch (err) {
|
|
898
906
|
next(err);
|
|
899
907
|
}
|