@noverax/courier-sveltekit 0.2.0 → 0.3.1

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/README.md CHANGED
@@ -41,7 +41,7 @@ The SvelteKit adapter serves Courier's proxy from a `+server.ts` endpoint on Web
41
41
  <tr>
42
42
  <td width="33%" valign="top">
43
43
  <h4>One endpoint</h4>
44
- <code>courierHandler()</code> in <code>src/routes/api/request/+server.ts</code> answers every endpoint the boundary exposes.
44
+ <code>courierHandler()</code> in <code>src/routes/api/request/+server.ts</code> answers every endpoint marked <code>.expose()</code>.
45
45
  </td>
46
46
  <td width="33%" valign="top">
47
47
  <h4>The user's session</h4>
@@ -131,11 +131,11 @@ Pair with `createProxyCaller` on the client:
131
131
 
132
132
  ```ts
133
133
  import { createProxyCaller } from "@noverax/courier"
134
- import type { api } from "./api"
134
+ import { apiRoutes } from "./courier.routes"
135
135
 
136
- // The first argument is the key this source has in your `sources` map —
137
- // it is what the proxy addresses, and it travels as `?_s=<name>`.
138
- const caller = createProxyCaller<typeof api>("api", {
136
+ // The routes Courier writes from the endpoints you mark .expose():
137
+ // what a page may call, under the key the source has in your `sources` map.
138
+ const caller = createProxyCaller(apiRoutes, {
139
139
  proxyPath: { http: "/api/request" },
140
140
  })
141
141
  const users = await caller.users.getAll()
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { n as svelteKitRequestContext, r as svelteKitClientAddress, t as svelteKitIncomingRequest } from "./request-context-UtZzeQWD.js";
2
2
  import { createHandler, handleWhileConnected } from "@noverax/courier";
3
3
  import { announceWhenRegistered } from "@noverax/courier/announce";
4
- import { rememberPeerAddress } from "@noverax/courier/internal";
4
+ import { rememberPeerAddress, serverOriginOf } from "@noverax/courier/internal";
5
5
  //#region src/index.ts
6
6
  /**
7
7
  * Create a SvelteKit request handler for the courier proxy.
@@ -41,8 +41,8 @@ function courierHandler(config) {
41
41
  framework: "sveltekit"
42
42
  });
43
43
  return (event) => {
44
- announce(new URL(event.request.url).origin);
45
44
  rememberPeerAddress(event.request, svelteKitClientAddress(event));
45
+ announce(serverOriginOf(event.platform?.req?.socket));
46
46
  return handleWhileConnected(handle, event.request, event.platform?.req?.socket);
47
47
  };
48
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noverax/courier-sveltekit",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "SvelteKit adapter for Courier: an endpoint that proxies typed calls to any backend, with the user's session in load functions and form actions",
5
5
  "keywords": [
6
6
  "courier",
@@ -72,7 +72,7 @@
72
72
  "access": "public"
73
73
  },
74
74
  "peerDependencies": {
75
- "@noverax/courier": "^0.2.0"
75
+ "@noverax/courier": "^0.3.1"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@noverax/courier": "*"