@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.
@@ -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 interpolatedPath = path;
11
+ let resolvedPath = `${options.basePath ?? ""}${path}`;
12
12
  for (const [key, value] of Object.entries(ctx?.params ?? {})) {
13
- interpolatedPath = interpolatedPath.replace(`:${key}`, String(value));
13
+ resolvedPath = resolvedPath.replace(`:${key}`, String(value));
14
14
  }
15
- const url = new URL(interpolatedPath, baseURL);
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 interpolatedPath = path;
35
+ let resolvedPath = `${options.basePath ?? ""}${path}`;
36
36
  for (const [key, value] of Object.entries(ctx?.params ?? {})) {
37
- interpolatedPath = interpolatedPath.replace(`:${key}`, String(value));
37
+ resolvedPath = resolvedPath.replace(`:${key}`, String(value));
38
38
  }
39
- const url = new URL(interpolatedPath, baseURL);
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
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createClient
3
- } from "./chunk-MP4L2ICK.js";
3
+ } from "./chunk-SP2NSNB2.js";
4
4
  export {
5
5
  createClient
6
6
  };
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 interpolatedPath = path;
443
+ let resolvedPath = `${options.basePath ?? ""}${path}`;
444
444
  for (const [key, value] of Object.entries(ctx?.params ?? {})) {
445
- interpolatedPath = interpolatedPath.replace(`:${key}`, String(value));
445
+ resolvedPath = resolvedPath.replace(`:${key}`, String(value));
446
446
  }
447
- const url = new URL(interpolatedPath, baseURL);
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
@@ -4,7 +4,7 @@ import {
4
4
  import "./chunk-6CIHAUKJ.js";
5
5
  import {
6
6
  createClient
7
- } from "./chunk-MP4L2ICK.js";
7
+ } from "./chunk-SP2NSNB2.js";
8
8
  import "./chunk-SY4MM2AG.js";
9
9
  import {
10
10
  createEndpoint,
@@ -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<Response | GlobalMiddlewareContext>;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aura-stack/router",
3
- "version": "0.6.0-rc.1",
3
+ "version": "0.6.0-rc.2",
4
4
  "type": "module",
5
5
  "description": "A lightweight TypeScript library for building, managing, and validating API routes and endpoints in Node.js applications.",
6
6
  "repository": {