@atscript/moost-db 0.1.53 → 0.1.54

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/index.cjs CHANGED
@@ -229,8 +229,15 @@ let AsDbReadableController = class AsDbReadableController {
229
229
  }
230
230
  /** Sets @db.http.path on the type metadata from the controller's computed prefix. */
231
231
  _resolveHttpPath() {
232
- const overview = this.app.getControllersOverview?.()?.find((o) => o.type === this.constructor);
233
- if (overview?.computedPrefix) this.readable.type.metadata.set("db.http.path", overview.computedPrefix);
232
+ let prefix;
233
+ try {
234
+ prefix = (0, moost.useControllerContext)().getPrefix();
235
+ } catch {}
236
+ if (!prefix) prefix = (this.app.getControllersOverview?.()?.find((o) => o.type === this.constructor))?.computedPrefix;
237
+ if (prefix) {
238
+ if (!prefix.startsWith("/")) prefix = `/${prefix}`;
239
+ this.readable.type.metadata.set("db.http.path", prefix);
240
+ }
234
241
  }
235
242
  /** Lazily serializes the type (after all controllers have set their @db.http.path). */
236
243
  getSerializedType() {
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ValidatorError, defineAnnotatedType, serializeAnnotatedType, throwFeatureDisabled } from "@atscript/typescript/utils";
2
2
  import { Body, Delete, Get, HttpError, Patch, Post, Put, Query, Url } from "@moostjs/event-http";
3
- import { ApplyDecorators, Controller, Inherit, Inject, Intercept, Moost, Param, Provide, TInterceptorPriority, defineInterceptor } from "moost";
3
+ import { ApplyDecorators, Controller, Inherit, Inject, Intercept, Moost, Param, Provide, TInterceptorPriority, defineInterceptor, useControllerContext } from "moost";
4
4
  import { parseUrl } from "@uniqu/url";
5
5
  import { DbError } from "@atscript/db";
6
6
  //#region src/decorators.ts
@@ -228,8 +228,15 @@ let AsDbReadableController = class AsDbReadableController {
228
228
  }
229
229
  /** Sets @db.http.path on the type metadata from the controller's computed prefix. */
230
230
  _resolveHttpPath() {
231
- const overview = this.app.getControllersOverview?.()?.find((o) => o.type === this.constructor);
232
- if (overview?.computedPrefix) this.readable.type.metadata.set("db.http.path", overview.computedPrefix);
231
+ let prefix;
232
+ try {
233
+ prefix = useControllerContext().getPrefix();
234
+ } catch {}
235
+ if (!prefix) prefix = (this.app.getControllersOverview?.()?.find((o) => o.type === this.constructor))?.computedPrefix;
236
+ if (prefix) {
237
+ if (!prefix.startsWith("/")) prefix = `/${prefix}`;
238
+ this.readable.type.metadata.set("db.http.path", prefix);
239
+ }
233
240
  }
234
241
  /** Lazily serializes the type (after all controllers have set their @db.http.path). */
235
242
  getSerializedType() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/moost-db",
3
- "version": "0.1.53",
3
+ "version": "0.1.54",
4
4
  "description": "Generic database controller for Moost with Atscript.",
5
5
  "keywords": [
6
6
  "annotations",
@@ -53,7 +53,7 @@
53
53
  "@moostjs/event-http": "^0.6.7",
54
54
  "@uniqu/core": "^0.1.5",
55
55
  "moost": "^0.6.7",
56
- "@atscript/db": "^0.1.53"
56
+ "@atscript/db": "^0.1.54"
57
57
  },
58
58
  "scripts": {
59
59
  "postinstall": "asc -f dts",