@dooboostore/simple-boot-http-server 1.0.31 → 1.0.32

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.
@@ -25584,26 +25584,45 @@ var SimstanceManager = class _SimstanceManager {
25584
25584
  return registed.instance;
25585
25585
  }
25586
25586
  if (this.storage.has(targetKey) && void 0 === registed?.instance) {
25587
- newInstanceCarrier.depth++;
25588
- const newSim = this.newSim({
25589
- target: registed?.type ?? targetKey,
25590
- newInstanceCarrier,
25591
- simCreateAfter: (data) => {
25592
- if (getSim(registed?.type ?? target ?? targetKey)?.scope === Lifecycle.Singleton) {
25593
- this.setStoreSet(targetKey, data, target);
25587
+ const resolving = newInstanceCarrier.resolving ??= [];
25588
+ if (resolving.includes(targetKey)) {
25589
+ const nameOf = (t) => typeof t === "symbol" ? t.toString() : t?.name ?? String(t);
25590
+ throw new Error(
25591
+ `Circular dependency detected: ${[...resolving.map(nameOf), nameOf(targetKey)].join(" -> ")}`
25592
+ );
25593
+ }
25594
+ resolving.push(targetKey);
25595
+ let settled = false;
25596
+ try {
25597
+ newInstanceCarrier.depth++;
25598
+ const newSim = this.newSim({
25599
+ target: registed?.type ?? targetKey,
25600
+ newInstanceCarrier,
25601
+ simCreateAfter: (data) => {
25602
+ if (getSim(registed?.type ?? target ?? targetKey)?.scope === Lifecycle.Singleton) {
25603
+ this.setStoreSet(targetKey, data, target);
25604
+ }
25594
25605
  }
25595
- }
25596
- });
25597
- newInstanceCarrier.depth--;
25598
- if (newInstanceCarrier.depth === 0) {
25599
- newInstanceCarrier.newInstances.forEach((it) => {
25600
- this.callBindPostConstruct(it);
25601
25606
  });
25607
+ newInstanceCarrier.depth--;
25608
+ resolving.pop();
25609
+ settled = true;
25610
+ if (newInstanceCarrier.depth === 0) {
25611
+ newInstanceCarrier.newInstances.forEach((it) => {
25612
+ this.callBindPostConstruct(it);
25613
+ });
25614
+ }
25615
+ if (isOnSimCreate(newSim)) {
25616
+ newSim.onSimCreate();
25617
+ }
25618
+ return newSim;
25619
+ } finally {
25620
+ if (!settled) {
25621
+ newInstanceCarrier.depth--;
25622
+ const idx = resolving.lastIndexOf(targetKey);
25623
+ if (idx !== -1) resolving.splice(idx, 1);
25624
+ }
25602
25625
  }
25603
- if (isOnSimCreate(newSim)) {
25604
- newSim.onSimCreate();
25605
- }
25606
- return newSim;
25607
25626
  }
25608
25627
  const simNoSuch = new SimNoSuch("SimNoSuch: no simple instance(resolve) name:" + targetKey?.prototype?.constructor?.name + "," + targetKey);
25609
25628
  console.error(simNoSuch);
@@ -28851,7 +28870,12 @@ var RequestResponse = class _RequestResponse {
28851
28870
  return data;
28852
28871
  }
28853
28872
  async reqBodyJsonData() {
28854
- return JSON.parse(await this.reqBodyStringData());
28873
+ const raw = await this.reqBodyStringData();
28874
+ try {
28875
+ return JSON.parse(raw);
28876
+ } catch (e) {
28877
+ throw new BadRequestError({ message: `Invalid JSON body: ${e?.message ?? e}` });
28878
+ }
28855
28879
  }
28856
28880
  async reqBodyFormUrlData() {
28857
28881
  const data = await this.reqBodyStringData();
@@ -28874,7 +28898,14 @@ var RequestResponse = class _RequestResponse {
28874
28898
  }
28875
28899
  async reqBodyReqJsonBody() {
28876
28900
  const data = await this.reqBodyStringData();
28877
- return Object.assign(new ReqJsonBody(), data ? JSON.parse(data) : {});
28901
+ if (!data) {
28902
+ return Object.assign(new ReqJsonBody(), {});
28903
+ }
28904
+ try {
28905
+ return Object.assign(new ReqJsonBody(), JSON.parse(data));
28906
+ } catch (e) {
28907
+ throw new BadRequestError({ message: `Invalid JSON body: ${e?.message ?? e}` });
28908
+ }
28878
28909
  }
28879
28910
  resBodyJsonData() {
28880
28911
  const data = ConvertUtils2.toString(this.resBodyData());
@@ -29213,7 +29244,7 @@ var HttpServerOption = class _HttpServerOption extends SimOption {
29213
29244
  );
29214
29245
  this.globalAdvice = globalAdvice;
29215
29246
  this.fileUploadTempPath = fileUploadTempPath;
29216
- this.noSuchRouteEndPointMappingThrow = noSuchRouteEndPointMappingThrow;
29247
+ this.noSuchRouteEndPointMappingThrow = noSuchRouteEndPointMappingThrow ?? ((rr) => new NotFoundError({ message: `no route ${rr.reqMethod?.() ?? ""} ${rr.reqUrlPathName ?? ""}`.trim() }));
29217
29248
  this.transactionManagerFactory = transactionManagerFactory;
29218
29249
  }
29219
29250
  get hostname() {
@@ -29957,12 +29988,12 @@ var ElementApply = class _ElementApply {
29957
29988
  const endPrefix = `${eaPrefix}:${eaId}:end:${type}`;
29958
29989
  let next = node.nextSibling;
29959
29990
  while (next) {
29960
- if (next.nodeType === Node.COMMENT_NODE && next.data?.trim?.()?.startsWith(endPrefix)) {
29991
+ if (next.nodeType === this.window.Node.COMMENT_NODE && next.data?.trim?.()?.startsWith(endPrefix)) {
29961
29992
  return { nodeType: "comment", type, start: node, end: next, script: script ?? "", variables: this.findVariables(script) };
29962
29993
  }
29963
29994
  next = next.nextSibling;
29964
29995
  }
29965
- } else if (node.nodeType === Node.ELEMENT_NODE) {
29996
+ } else if (node.nodeType === this.window.Node.ELEMENT_NODE) {
29966
29997
  const aa = node.getAttributeNames().filter((name) => {
29967
29998
  return name.startsWith(`ea:${id}:attribute:`) || name.startsWith(`ea:${id}:event:`) || name.startsWith(`ea:${id}:property:`);
29968
29999
  });