@aura-stack/router 0.6.0-rc.1 → 0.6.0-rc.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/{chunk-MP4L2ICK.js → chunk-SP2NSNB2.js} +3 -3
- package/dist/client.cjs +3 -3
- package/dist/client.js +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +1 -1
- package/dist/middlewares.d.ts +1 -1
- package/dist/types.d.ts +4 -0
- package/package.json +1 -1
|
@@ -8,11 +8,11 @@ function createClient(options) {
|
|
|
8
8
|
const method = prop.toString().toUpperCase();
|
|
9
9
|
return async (path, ctx) => {
|
|
10
10
|
const searchParams = new URLSearchParams(ctx?.searchParams);
|
|
11
|
-
let
|
|
11
|
+
let resolvedPath = `${options.basePath ?? ""}${path}`;
|
|
12
12
|
for (const [key, value] of Object.entries(ctx?.params ?? {})) {
|
|
13
|
-
|
|
13
|
+
resolvedPath = resolvedPath.replace(`:${key}`, String(value));
|
|
14
14
|
}
|
|
15
|
-
const url = new URL(
|
|
15
|
+
const url = new URL(resolvedPath, baseURL);
|
|
16
16
|
if (searchParams.size > 0) {
|
|
17
17
|
url.search = searchParams.toString();
|
|
18
18
|
}
|
package/dist/client.cjs
CHANGED
|
@@ -32,11 +32,11 @@ function createClient(options) {
|
|
|
32
32
|
const method = prop.toString().toUpperCase();
|
|
33
33
|
return async (path, ctx) => {
|
|
34
34
|
const searchParams = new URLSearchParams(ctx?.searchParams);
|
|
35
|
-
let
|
|
35
|
+
let resolvedPath = `${options.basePath ?? ""}${path}`;
|
|
36
36
|
for (const [key, value] of Object.entries(ctx?.params ?? {})) {
|
|
37
|
-
|
|
37
|
+
resolvedPath = resolvedPath.replace(`:${key}`, String(value));
|
|
38
38
|
}
|
|
39
|
-
const url = new URL(
|
|
39
|
+
const url = new URL(resolvedPath, baseURL);
|
|
40
40
|
if (searchParams.size > 0) {
|
|
41
41
|
url.search = searchParams.toString();
|
|
42
42
|
}
|
package/dist/client.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -440,11 +440,11 @@ function createClient(options) {
|
|
|
440
440
|
const method = prop.toString().toUpperCase();
|
|
441
441
|
return async (path, ctx) => {
|
|
442
442
|
const searchParams = new URLSearchParams(ctx?.searchParams);
|
|
443
|
-
let
|
|
443
|
+
let resolvedPath = `${options.basePath ?? ""}${path}`;
|
|
444
444
|
for (const [key, value] of Object.entries(ctx?.params ?? {})) {
|
|
445
|
-
|
|
445
|
+
resolvedPath = resolvedPath.replace(`:${key}`, String(value));
|
|
446
446
|
}
|
|
447
|
-
const url = new URL(
|
|
447
|
+
const url = new URL(resolvedPath, baseURL);
|
|
448
448
|
if (searchParams.size > 0) {
|
|
449
449
|
url.search = searchParams.toString();
|
|
450
450
|
}
|
package/dist/index.js
CHANGED
package/dist/middlewares.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import 'http';
|
|
|
12
12
|
* @param middlewares - Array of global middleware functions to be executed
|
|
13
13
|
* @returns - The modified request after all middlewares have been executed
|
|
14
14
|
*/
|
|
15
|
-
declare const executeGlobalMiddlewares: (context: GlobalMiddlewareContext, middlewares: RouterConfig["middlewares"]) => Promise<
|
|
15
|
+
declare const executeGlobalMiddlewares: (context: GlobalMiddlewareContext, middlewares: RouterConfig["middlewares"]) => Promise<GlobalMiddlewareContext | Response>;
|
|
16
16
|
/**
|
|
17
17
|
* Executes middlewares in sequence, passing the request and context to each middleware.
|
|
18
18
|
*
|
package/dist/types.d.ts
CHANGED
|
@@ -251,6 +251,10 @@ interface ClientOptions {
|
|
|
251
251
|
* baseURL: "https://api.example.com"
|
|
252
252
|
*/
|
|
253
253
|
baseURL: string;
|
|
254
|
+
/**
|
|
255
|
+
* Optional base path to prepend to all request paths made by the client.
|
|
256
|
+
*/
|
|
257
|
+
basePath?: RoutePattern;
|
|
254
258
|
/**
|
|
255
259
|
* Default headers to include in every request made by the client.
|
|
256
260
|
*/
|
package/package.json
CHANGED