@luminix/core 0.3.1 → 0.3.2
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/core.js +5 -3
- package/package.json +1 -1
- package/types/services/RouteService.d.ts +1 -0
package/dist/core.js
CHANGED
|
@@ -1372,19 +1372,21 @@ class Be {
|
|
|
1372
1372
|
return d.get(this.routes, t);
|
|
1373
1373
|
}
|
|
1374
1374
|
url(t) {
|
|
1375
|
+
return this.appUrl + this.path(t);
|
|
1376
|
+
}
|
|
1377
|
+
path(t) {
|
|
1375
1378
|
const [e, i] = this.extractGenerator(t), s = this.get(e)[0].replace(/^\/|\/$/g, ""), c = /{([^}]+)}/g;
|
|
1376
1379
|
if (i === !1) {
|
|
1377
1380
|
if (typeof this.replaceRouteParams != "function")
|
|
1378
1381
|
throw new E("RouteFacade");
|
|
1379
|
-
return this.
|
|
1382
|
+
return this.replaceRouteParams(`/${s}`);
|
|
1380
1383
|
}
|
|
1381
1384
|
const y = s.match(c), l = y ? y.map((h) => h.slice(1, -1)) : [], u = Object.keys(i), r = l.filter((h) => !u.includes(h)), n = u.filter((h) => !l.includes(h));
|
|
1382
1385
|
if (r.length > 0)
|
|
1383
1386
|
throw new TypeError(`Missing values for parameter(s): ${r.join(", ")}`);
|
|
1384
1387
|
if (n.length > 0)
|
|
1385
1388
|
throw new TypeError(`Unexpected parameters: ${n.join(", ")}`);
|
|
1386
|
-
|
|
1387
|
-
return this.appUrl + `/${a}`;
|
|
1389
|
+
return `/${l.reduce((h, g) => h.replace(`{${g}}`, `${i[g]}`), s)}`;
|
|
1388
1390
|
}
|
|
1389
1391
|
methods(t) {
|
|
1390
1392
|
const [e] = this.extractGenerator(t);
|
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ export declare class RouteService {
|
|
|
11
11
|
private extractGenerator;
|
|
12
12
|
get(name: string): RouteTuple;
|
|
13
13
|
url(generator: RouteGenerator): string;
|
|
14
|
+
path(generator: RouteGenerator): string;
|
|
14
15
|
methods(generator: RouteGenerator): HttpMethod[];
|
|
15
16
|
exists(name: string): boolean;
|
|
16
17
|
call<TResponse = any>(generator: RouteGenerator, tap?: (client: Client) => Client, errorBag?: string): Promise<Response<TResponse>>;
|