@fougere/app 0.6.0-alpha.0 → 0.7.0-alpha.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/dist/auth.d.ts +1 -7
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js.map +1 -1
- package/dist/boot.d.ts +14 -85
- package/dist/boot.d.ts.map +1 -1
- package/dist/boot.js +17 -77
- package/dist/boot.js.map +1 -1
- package/dist/client.d.ts +5 -24
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +6 -32
- package/dist/client.js.map +1 -1
- package/dist/express.d.ts +2 -12
- package/dist/express.d.ts.map +1 -1
- package/dist/express.js +4 -52
- package/dist/express.js.map +1 -1
- package/dist/form.d.ts +11 -56
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js +15 -33
- package/dist/form.js.map +1 -1
- package/dist/graphql.d.ts +2 -28
- package/dist/graphql.d.ts.map +1 -1
- package/dist/graphql.js +1 -6
- package/dist/graphql.js.map +1 -1
- package/dist/index.d.ts +1 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -11
- package/dist/index.js.map +1 -1
- package/dist/rest.d.ts +2 -16
- package/dist/rest.d.ts.map +1 -1
- package/dist/rest.js +4 -34
- package/dist/rest.js.map +1 -1
- package/dist/serve.d.ts +10 -57
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +12 -55
- package/dist/serve.js.map +1 -1
- package/dist/session.d.ts +2 -7
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +2 -7
- package/dist/session.js.map +1 -1
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +1 -11
- package/dist/state.js.map +1 -1
- package/dist/web.d.ts +3 -19
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +4 -32
- package/dist/web.js.map +1 -1
- package/package.json +11 -11
- package/src/auth.ts +1 -7
- package/src/boot.ts +28 -134
- package/src/client.ts +7 -33
- package/src/express.ts +4 -52
- package/src/form.ts +20 -73
- package/src/graphql.ts +2 -28
- package/src/index.ts +1 -11
- package/src/rest.ts +4 -34
- package/src/serve.ts +13 -60
- package/src/session.ts +2 -7
- package/src/state.ts +1 -11
- package/src/web.ts +4 -32
package/src/web.ts
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The three doors as Web-standard handlers: `Request` in, `Response` out.
|
|
3
|
-
*
|
|
4
|
-
* This is the whole server surface for any host built on fetch semantics — Next
|
|
5
|
-
* route handlers, TanStack Start server routes, Hono, a bare `Deno.serve`. Such a
|
|
6
|
-
* host mounts these; it does not translate anything, because there is nothing left
|
|
7
|
-
* to translate.
|
|
8
|
-
*
|
|
9
|
-
* Nuxt is the exception and keeps its own translation, for a reason worth stating:
|
|
10
|
-
* an h3 event is not a `Request`, and reading its body has to straddle two h3
|
|
11
|
-
* majors (`server/routes/call.post.ts` carries that hundred lines). That file is
|
|
12
|
-
* what a NON-Web-standard host costs.
|
|
13
|
-
*/
|
|
1
|
+
/** The three doors as Web-standard handlers: `Request` in, `Response` out. */
|
|
14
2
|
import { serveRest, serveRpc, rpcParseError, useFougereApp, serveGraphQL } from './index.js';
|
|
15
3
|
import { MAX_BODY_BYTES } from '@fougere/core';
|
|
16
4
|
import { sessionViewOf } from './session.js';
|
|
@@ -18,11 +6,7 @@ import { stateFor } from './state.js';
|
|
|
18
6
|
|
|
19
7
|
const WITH_BODY = new Set(['POST', 'PUT', 'PATCH']);
|
|
20
8
|
|
|
21
|
-
/**
|
|
22
|
-
* The call envelope. A named surface is the path segment after the door —
|
|
23
|
-
* `/_fougere/call/public` serves the `public` audience — and `surfaceOf` reads it,
|
|
24
|
-
* so a host only has to mount this at a path that keeps the segments.
|
|
25
|
-
*/
|
|
9
|
+
/** The call envelope. */
|
|
26
10
|
export async function fougereCall(request: Request): Promise<Response> {
|
|
27
11
|
const declared = Number(request.headers.get('content-length'));
|
|
28
12
|
if (Number.isFinite(declared) && declared > MAX_BODY_BYTES) {
|
|
@@ -46,14 +30,7 @@ export async function fougereCall(request: Request): Promise<Response> {
|
|
|
46
30
|
);
|
|
47
31
|
}
|
|
48
32
|
|
|
49
|
-
/**
|
|
50
|
-
* The REST projection, mounted under `/api`.
|
|
51
|
-
*
|
|
52
|
-
* `pass` — a path this app does not serve — becomes a 404 here rather than a
|
|
53
|
-
* fall-through, because a Web handler has nobody to fall through to. Hosts that
|
|
54
|
-
* resolve a static route before a catch-all (Next does) still let an app keep its
|
|
55
|
-
* own `/api/*` handlers: they are reached BEFORE this one, not after.
|
|
56
|
-
*/
|
|
33
|
+
/** The REST projection, mounted under `/api`. */
|
|
57
34
|
export async function fougereRest(request: Request): Promise<Response> {
|
|
58
35
|
const app = await useFougereApp();
|
|
59
36
|
const url = new URL(request.url);
|
|
@@ -81,12 +58,7 @@ export async function fougereSession(request: Request): Promise<Response> {
|
|
|
81
58
|
return Response.json(sessionViewOf(await stateFor(request.headers)));
|
|
82
59
|
}
|
|
83
60
|
|
|
84
|
-
/**
|
|
85
|
-
* GraphQL, at whatever path the host mounted it — `/graphql` by convention.
|
|
86
|
-
*
|
|
87
|
-
* Answers `404` when the app declares no GraphQL adapter, because unlike REST this
|
|
88
|
-
* door is mounted at a path of its own: there is no app route underneath it to pass to.
|
|
89
|
-
*/
|
|
61
|
+
/** GraphQL, at whatever path the host mounted it — `/graphql` by convention. */
|
|
90
62
|
export async function fougereGraphQL(request: Request): Promise<Response> {
|
|
91
63
|
const app = await useFougereApp();
|
|
92
64
|
const body = (await request.json().catch(() => ({}))) as {
|