@noverax/courier-sveltekit 0.4.0 → 0.6.0
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 +6 -6
- package/lib/handle.d.ts +1 -1
- package/lib/handle.js +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/plugin.d.ts +15 -0
- package/lib/{request-context-CCrSKMZT.d.ts → request-context-C96e5HoI.d.ts} +2 -2
- package/lib/{request-context-D_B34mll.js → request-context-Cy7IqxdJ.js} +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -92,9 +92,9 @@ npm install @noverax/courier-sveltekit @noverax/courier @sveltejs/kit
|
|
|
92
92
|
|
|
93
93
|
## Usage
|
|
94
94
|
|
|
95
|
-
```ts
|
|
95
|
+
```ts side="server"
|
|
96
96
|
// src/hooks.server.ts
|
|
97
|
-
import { registerSources } from "@noverax/courier"
|
|
97
|
+
import { registerSources } from "@noverax/courier/server"
|
|
98
98
|
import { sources } from "$lib/api"
|
|
99
99
|
|
|
100
100
|
registerSources(sources)
|
|
@@ -161,8 +161,8 @@ declare module "@noverax/courier/routes" {
|
|
|
161
161
|
|
|
162
162
|
Then pair with `createProxyCaller` on the client:
|
|
163
163
|
|
|
164
|
-
```ts
|
|
165
|
-
import { createProxyCaller } from "@noverax/courier"
|
|
164
|
+
```ts side="page"
|
|
165
|
+
import { createProxyCaller } from "@noverax/courier/client"
|
|
166
166
|
import { routes } from "@noverax/courier/routes"
|
|
167
167
|
|
|
168
168
|
// What a page may call of the source registered as `api` in your `sources` map:
|
|
@@ -186,10 +186,10 @@ When the browser cancels a call — an aborted upload, a query it no longer need
|
|
|
186
186
|
|
|
187
187
|
An API that keeps the user's session describes it in `defineApi`, and every call a hook, a `load` function, a form action or an endpoint makes carries the session of the request being served — the cookies the session names and nothing else of your application's — once the request can be found:
|
|
188
188
|
|
|
189
|
-
```ts
|
|
189
|
+
```ts side="server"
|
|
190
190
|
// src/hooks.server.ts — SvelteKit 2.20 and later
|
|
191
191
|
import { getRequestEvent } from "$app/server"
|
|
192
|
-
import { registerRequestContext } from "@noverax/courier"
|
|
192
|
+
import { registerRequestContext } from "@noverax/courier/server"
|
|
193
193
|
import { svelteKitRequestContext } from "@noverax/courier-sveltekit"
|
|
194
194
|
|
|
195
195
|
registerRequestContext(svelteKitRequestContext(getRequestEvent))
|
package/lib/handle.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as SvelteKitServerEvent } from "./request-context-
|
|
1
|
+
import { t as SvelteKitServerEvent } from "./request-context-C96e5HoI.js";
|
|
2
2
|
/** A SvelteKit `handle` hook, as far as it reads its input. */
|
|
3
3
|
export type RequestContextHandle = <TEvent extends SvelteKitServerEvent, TResponse>(input: {
|
|
4
4
|
event: TEvent;
|
package/lib/handle.js
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as svelteKitIncomingRequest, r as svelteKitRequestContext, t as SvelteKitServerEvent } from "./request-context-
|
|
2
|
-
import { ClientConnection, ConnectResult, HandlerConfig } from "@noverax/courier";
|
|
1
|
+
import { n as svelteKitIncomingRequest, r as svelteKitRequestContext, t as SvelteKitServerEvent } from "./request-context-C96e5HoI.js";
|
|
2
|
+
import { ClientConnection, ConnectResult, HandlerConfig } from "@noverax/courier/server";
|
|
3
3
|
/**
|
|
4
4
|
* The parts of SvelteKit's `RequestEvent` the handler reads. `platform.req`
|
|
5
5
|
* is the Node request `@sveltejs/adapter-node` passes along.
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as svelteKitRequestContext, r as svelteKitClientAddress, t as svelteKitIncomingRequest } from "./request-context-
|
|
2
|
-
import { createHandler, handleWhileConnected } from "@noverax/courier";
|
|
1
|
+
import { n as svelteKitRequestContext, r as svelteKitClientAddress, t as svelteKitIncomingRequest } from "./request-context-Cy7IqxdJ.js";
|
|
3
2
|
import { announceWhenRegistered } from "@noverax/courier/announce";
|
|
4
3
|
import { rememberPeerAddress, serverOriginOf } from "@noverax/courier/internal";
|
|
4
|
+
import { createHandler, handleWhileConnected } from "@noverax/courier/server";
|
|
5
5
|
// src/index.ts
|
|
6
6
|
/**
|
|
7
7
|
* Create a SvelteKit request handler for the courier proxy.
|
package/lib/plugin.d.ts
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Vite plugin that builds a SvelteKit app's routes — what each page's
|
|
3
|
+
* proxy client may call — from `courier.config.ts`, for its pages and for
|
|
4
|
+
* the server that renders them. No routes file is written.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* // vite.config.ts
|
|
9
|
+
* import { sveltekit } from "@sveltejs/kit/vite";
|
|
10
|
+
* import { courierRoutes } from "@noverax/courier-sveltekit/plugin";
|
|
11
|
+
* import { defineConfig } from "vite";
|
|
12
|
+
*
|
|
13
|
+
* export default defineConfig({ plugins: [sveltekit(), courierRoutes()] });
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
1
16
|
import { CourierRoutesOptions, courierRoutes } from "@noverax/courier-build/vite";
|
|
2
17
|
export { type CourierRoutesOptions, courierRoutes };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IncomingRequest, RequestContextProvider } from "@noverax/courier";
|
|
1
|
+
import { IncomingRequest, RequestContextProvider } from "@noverax/courier/server";
|
|
2
2
|
/** A cookie's options, as SvelteKit's `cookies.set()` takes them. */
|
|
3
3
|
interface SvelteKitCookieOptions {
|
|
4
4
|
path: string;
|
|
@@ -33,7 +33,7 @@ interface SvelteKitServerEvent {
|
|
|
33
33
|
* ```ts
|
|
34
34
|
* // src/hooks.server.ts
|
|
35
35
|
* import { getRequestEvent } from "$app/server";
|
|
36
|
-
* import { registerRequestContext } from "@noverax/courier";
|
|
36
|
+
* import { registerRequestContext } from "@noverax/courier/server";
|
|
37
37
|
* import { svelteKitRequestContext } from "@noverax/courier-sveltekit";
|
|
38
38
|
*
|
|
39
39
|
* registerRequestContext(svelteKitRequestContext(getRequestEvent));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createLogger } from "@noverax/courier";
|
|
2
1
|
import { forwardedChain } from "@noverax/courier/internal";
|
|
2
|
+
import { createLogger } from "@noverax/courier/server";
|
|
3
3
|
// src/client-address.ts
|
|
4
4
|
const log$1 = createLogger("SvelteKit");
|
|
5
5
|
/**
|
|
@@ -37,7 +37,7 @@ const providers = /* @__PURE__ */ new WeakMap();
|
|
|
37
37
|
* ```ts
|
|
38
38
|
* // src/hooks.server.ts
|
|
39
39
|
* import { getRequestEvent } from "$app/server";
|
|
40
|
-
* import { registerRequestContext } from "@noverax/courier";
|
|
40
|
+
* import { registerRequestContext } from "@noverax/courier/server";
|
|
41
41
|
* import { svelteKitRequestContext } from "@noverax/courier-sveltekit";
|
|
42
42
|
*
|
|
43
43
|
* registerRequestContext(svelteKitRequestContext(getRequestEvent));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noverax/courier-sveltekit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
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",
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
|
-
"@noverax/courier": "^0.
|
|
84
|
-
"@noverax/courier-build": "^0.
|
|
83
|
+
"@noverax/courier": "^0.6.0",
|
|
84
|
+
"@noverax/courier-build": "^0.6.0",
|
|
85
85
|
"vite": ">=5.0.0"
|
|
86
86
|
},
|
|
87
87
|
"peerDependenciesMeta": {
|