@fedify/h3 0.1.2-dev.8 → 1.8.0-dev.936
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/LICENSE +1 -1
- package/README.md +5 -18
- package/dist/index.d.ts +6 -4
- package/dist/index.js +30 -27
- package/package.json +17 -16
- package/src/index.ts +0 -82
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
<!-- deno-fmt-ignore-file -->
|
|
2
|
+
|
|
1
3
|
@fedify/h3: Integrate Fedify with h3
|
|
2
4
|
====================================
|
|
3
5
|
|
|
6
|
+
[![JSR][JSR badge]][JSR]
|
|
4
7
|
[![npm][npm badge]][npm]
|
|
5
8
|
[![Matrix][Matrix badge]][Matrix]
|
|
6
9
|
[![Follow @fedify@hollo.social][@fedify@hollo.social badge]][@fedify@hollo.social]
|
|
@@ -33,6 +36,8 @@ app.use(router);
|
|
|
33
36
|
> If you don't do this, Fedify will not be able to respond with a proper error
|
|
34
37
|
> status code when a content negotiation fails.
|
|
35
38
|
|
|
39
|
+
[JSR]: https://jsr.io/@fedify/h3
|
|
40
|
+
[JSR badge]: https://jsr.io/badges/@fedify/h3
|
|
36
41
|
[npm]: https://www.npmjs.com/package/@fedify/h3
|
|
37
42
|
[npm badge]: https://img.shields.io/npm/v/@fedify/h3?logo=npm
|
|
38
43
|
[Matrix]: https://matrix.to/#/#fedify:matrix.org
|
|
@@ -46,21 +51,3 @@ app.use(router);
|
|
|
46
51
|
[Vinxi]: https://vinxi.vercel.app/
|
|
47
52
|
[SolidStart]: https://start.solidjs.com/
|
|
48
53
|
[TanStack Start]: https://tanstack.com/start
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Changelog
|
|
52
|
-
---------
|
|
53
|
-
|
|
54
|
-
### Version 0.1.2
|
|
55
|
-
|
|
56
|
-
To be released.
|
|
57
|
-
|
|
58
|
-
### Version 0.1.1
|
|
59
|
-
|
|
60
|
-
Released on August 6, 2024.
|
|
61
|
-
|
|
62
|
-
- Added missing entry points to the *package.json*.
|
|
63
|
-
|
|
64
|
-
### Version 0.1.0
|
|
65
|
-
|
|
66
|
-
Initial release. Released on July 6, 2024.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { EventHandler, EventHandlerRequest, EventHandlerResponse, H3Error, H3Event } from "h3";
|
|
2
|
+
import { Federation } from "@fedify/fedify";
|
|
3
|
+
|
|
4
|
+
//#region index.d.ts
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* A factory function that creates the context data that will be passed to the
|
|
@@ -27,5 +29,5 @@ declare function integrateFederation<TContextData>(federation: Federation<TConte
|
|
|
27
29
|
* @param event The event that triggered the handler.
|
|
28
30
|
*/
|
|
29
31
|
declare function onError(error: H3Error<unknown>, event: H3Event<EventHandlerResponse>): Promise<void>;
|
|
30
|
-
|
|
31
|
-
export {
|
|
32
|
+
//#endregion
|
|
33
|
+
export { ContextDataFactory, integrateFederation, onError };
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { defineEventHandler, toWebRequest } from "h3";
|
|
2
|
+
|
|
3
|
+
//#region index.ts
|
|
4
|
+
/**
|
|
5
|
+
* Integrates a `Federation` instance with an H3 handler.
|
|
6
|
+
* @param federation
|
|
7
|
+
* @param contextDataFactory
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
6
10
|
function integrateFederation(federation, contextDataFactory) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
await event.respondWith(response);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
11
|
+
return defineEventHandler({ async handler(event) {
|
|
12
|
+
const request = toWebRequest(event);
|
|
13
|
+
const response = await federation.fetch(request, { contextData: await contextDataFactory(event, request) });
|
|
14
|
+
if (response.status === 404) return;
|
|
15
|
+
if (response.status === 406) {
|
|
16
|
+
event.context["__fedify_response__"] = response;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
await event.respondWith(response);
|
|
20
|
+
} });
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* An error handler that responds with a 406 Not Acceptable if Fedify
|
|
24
|
+
* responded with a 406 Not Acceptable and the actual handler responded with
|
|
25
|
+
* a 404 Not Found.
|
|
26
|
+
* @param error The error that occurred.
|
|
27
|
+
* @param event The event that triggered the handler.
|
|
28
|
+
*/
|
|
22
29
|
async function onError(error, event) {
|
|
23
|
-
|
|
24
|
-
await event.respondWith(event.context["__fedify_response__"]);
|
|
25
|
-
}
|
|
30
|
+
if ("__fedify_response__" in event.context && event.context["__fedify_response__"].status === 406 && error.statusCode === 404) await event.respondWith(event.context["__fedify_response__"]);
|
|
26
31
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2luZGV4LnRzIl0sCiAgInNvdXJjZXNDb250ZW50IjogWyJpbXBvcnQgdHlwZSB7IEZlZGVyYXRpb24gfSBmcm9tIFwiQGZlZGlmeS9mZWRpZnlcIjtcbmltcG9ydCB7XG4gIHR5cGUgRXZlbnRIYW5kbGVyLFxuICB0eXBlIEV2ZW50SGFuZGxlclJlcXVlc3QsXG4gIHR5cGUgRXZlbnRIYW5kbGVyUmVzcG9uc2UsXG4gIHR5cGUgSDNFcnJvcixcbiAgdHlwZSBIM0V2ZW50LFxuICBkZWZpbmVFdmVudEhhbmRsZXIsXG4gIHRvV2ViUmVxdWVzdCxcbn0gZnJvbSBcImgzXCI7XG5cbi8qKlxuICogQSBmY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FBTSxNQUFNLFlBQVksUUFBUTtBQUFBLElBQ2xDO0FBQUEsRUFDRixDQUFDO0FBQ0g7QUFTQSxlQUFzQixRQUNwQixPQUNBLE9BQ2U7QUFPZixNQUNFLHlCQUF5QixNQUFNLFdBQy9CLE1BQU0sUUFBUSxxQkFBcUIsRUFBRSxXQUFXLE9BQ2hELE1BQU0sZUFBZSxLQUNyQjtBQUNBLFVBQU0sTUFBTSxZQUFZLE1BQU0sUUFBUSxxQkFBcUIsQ0FBQztBQUFBLEVBQzlEO0FBQ0Y7IiwKICAibmFtZXMiOiBbXQp9Cg==
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { integrateFederation, onError };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/h3",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.8.0-dev.936+bb1d6663",
|
|
4
4
|
"description": "Integrate Fedify with h3",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Fedify",
|
|
@@ -11,16 +11,18 @@
|
|
|
11
11
|
"email": "hong@minhee.org",
|
|
12
12
|
"url": "https://hongminhee.org/"
|
|
13
13
|
},
|
|
14
|
-
"homepage": "https://
|
|
14
|
+
"homepage": "https://fedify.dev/",
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/fedify-dev/
|
|
17
|
+
"url": "git+https://github.com/fedify-dev/fedify.git",
|
|
18
|
+
"directory": "h3"
|
|
18
19
|
},
|
|
19
20
|
"license": "MIT",
|
|
20
21
|
"bugs": {
|
|
21
|
-
"url": "https://github.com/fedify-dev/
|
|
22
|
+
"url": "https://github.com/fedify-dev/fedify/issues"
|
|
22
23
|
},
|
|
23
24
|
"funding": [
|
|
25
|
+
"https://opencollective.com/fedify",
|
|
24
26
|
"https://github.com/sponsors/dahlia"
|
|
25
27
|
],
|
|
26
28
|
"type": "module",
|
|
@@ -32,24 +34,23 @@
|
|
|
32
34
|
"types": "./dist/index.d.ts",
|
|
33
35
|
"default": "./dist/index.js"
|
|
34
36
|
}
|
|
35
|
-
}
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
36
39
|
},
|
|
37
40
|
"files": [
|
|
38
|
-
"
|
|
39
|
-
"
|
|
41
|
+
"dist/",
|
|
42
|
+
"package.json"
|
|
40
43
|
],
|
|
41
44
|
"devDependencies": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"tsup": "^8.1.0",
|
|
45
|
-
"typescript": "^5.0.0"
|
|
45
|
+
"tsdown": "^0.12.9",
|
|
46
|
+
"typescript": "^5.8.3"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
|
-
"
|
|
49
|
-
"
|
|
49
|
+
"h3": "^1.15.0",
|
|
50
|
+
"@fedify/fedify": "1.8.0-dev.936+bb1d6663"
|
|
50
51
|
},
|
|
51
52
|
"scripts": {
|
|
52
|
-
"build": "
|
|
53
|
-
"
|
|
53
|
+
"build": "tsdown",
|
|
54
|
+
"prepublish": "tsdown"
|
|
54
55
|
}
|
|
55
|
-
}
|
|
56
|
+
}
|
package/src/index.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { Federation } from "@fedify/fedify";
|
|
2
|
-
import {
|
|
3
|
-
type EventHandler,
|
|
4
|
-
type EventHandlerRequest,
|
|
5
|
-
type EventHandlerResponse,
|
|
6
|
-
type H3Error,
|
|
7
|
-
type H3Event,
|
|
8
|
-
defineEventHandler,
|
|
9
|
-
toWebRequest,
|
|
10
|
-
} from "h3";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* A factory function that creates the context data that will be passed to the
|
|
14
|
-
* `Federation` instance.
|
|
15
|
-
* @typeParam TContextData The type of the context data that will be passed to
|
|
16
|
-
* the `Federation` instance.
|
|
17
|
-
* @param event The event that triggered the handler.
|
|
18
|
-
* @param request The request that triggered the handler.
|
|
19
|
-
* @returns The context data that will be passed to the `Federation` instance.
|
|
20
|
-
* This can be a promise that resolves to the context data.
|
|
21
|
-
*/
|
|
22
|
-
export type ContextDataFactory<TContextData> = (
|
|
23
|
-
event: H3Event<EventHandlerRequest>,
|
|
24
|
-
request: Request,
|
|
25
|
-
) => Promise<TContextData> | TContextData;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Integrates a `Federation` instance with an H3 handler.
|
|
29
|
-
* @param federation
|
|
30
|
-
* @param contextDataFactory
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
export function integrateFederation<TContextData>(
|
|
34
|
-
federation: Federation<TContextData>,
|
|
35
|
-
contextDataFactory: ContextDataFactory<TContextData>,
|
|
36
|
-
): EventHandler<EventHandlerRequest, EventHandlerResponse> {
|
|
37
|
-
return defineEventHandler({
|
|
38
|
-
async handler(event) {
|
|
39
|
-
const request = toWebRequest(event);
|
|
40
|
-
const response = await federation.fetch(request, {
|
|
41
|
-
contextData: await contextDataFactory(event, request),
|
|
42
|
-
});
|
|
43
|
-
// If the response is 404 Not Found, then we delegate the handling to
|
|
44
|
-
// the next handler in the chain. This is because the handler might
|
|
45
|
-
// have an endpoint that Fedify does not have, and we want to give the
|
|
46
|
-
// handler a chance to respond to the request:
|
|
47
|
-
if (response.status === 404) return;
|
|
48
|
-
// See also onBeforeResponse() above:
|
|
49
|
-
if (response.status === 406) {
|
|
50
|
-
event.context["__fedify_response__"] = response;
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
await event.respondWith(response);
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* An error handler that responds with a 406 Not Acceptable if Fedify
|
|
60
|
-
* responded with a 406 Not Acceptable and the actual handler responded with
|
|
61
|
-
* a 404 Not Found.
|
|
62
|
-
* @param error The error that occurred.
|
|
63
|
-
* @param event The event that triggered the handler.
|
|
64
|
-
*/
|
|
65
|
-
export async function onError(
|
|
66
|
-
error: H3Error<unknown>,
|
|
67
|
-
event: H3Event<EventHandlerResponse>,
|
|
68
|
-
): Promise<void> {
|
|
69
|
-
// If Fedify responded with a 406 Not Acceptable and later on the actual
|
|
70
|
-
// handler responded with a 404 Not Found, then we consider it failed
|
|
71
|
-
// to negotiate a response. For example, if Fedify has an endpoint /foo
|
|
72
|
-
// that supports only application/activity+json and the handler has no
|
|
73
|
-
// endpoint /foo at all, then when a client requests /foo with
|
|
74
|
-
// Accept: text/html, it should respond with 406 Not Acceptable:
|
|
75
|
-
if (
|
|
76
|
-
"__fedify_response__" in event.context &&
|
|
77
|
-
event.context["__fedify_response__"].status === 406 &&
|
|
78
|
-
error.statusCode === 404
|
|
79
|
-
) {
|
|
80
|
-
await event.respondWith(event.context["__fedify_response__"]);
|
|
81
|
-
}
|
|
82
|
-
}
|