@fedify/hono 1.9.0-pr.388.1454 → 1.9.0-pr.388.1457
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 +65 -0
- package/dist/mod.d.ts +2 -0
- package/dist/mod.js +1 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<!-- deno-fmt-ignore-file -->
|
|
2
|
+
|
|
3
|
+
@fedify/hono: Integrate Fedify with Hono
|
|
4
|
+
========================================
|
|
5
|
+
|
|
6
|
+
[![JSR][JSR badge]][JSR]
|
|
7
|
+
[![npm][npm badge]][npm]
|
|
8
|
+
[![Follow @fedify@hollo.social][@fedify@hollo.social badge]][@fedify@hollo.social]
|
|
9
|
+
|
|
10
|
+
*This package is available since Fedify 1.9.0.*
|
|
11
|
+
|
|
12
|
+
This package provides a simple way to integrate [Fedify] with [Hono].
|
|
13
|
+
|
|
14
|
+
The integration code looks like this:
|
|
15
|
+
|
|
16
|
+
~~~~ typescript
|
|
17
|
+
import { createFederation } from "@fedify/fedify";
|
|
18
|
+
import { federation } from "@fedify/hono";
|
|
19
|
+
import { Hono } from "hono";
|
|
20
|
+
|
|
21
|
+
const fedi = createFederation<string>({
|
|
22
|
+
// Omitted for brevity; see the related section for details.
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const app = new Hono();
|
|
26
|
+
app.use(federation(fedi, (ctx) => "context data"));
|
|
27
|
+
~~~~
|
|
28
|
+
|
|
29
|
+
How it works
|
|
30
|
+
------------
|
|
31
|
+
|
|
32
|
+
Fedify behaves as a middleware that wraps around the Hono request handler.
|
|
33
|
+
The middleware intercepts the incoming HTTP requests and dispatches them to
|
|
34
|
+
the appropriate handler based on the request path and the `Accept` header
|
|
35
|
+
(i.e., content negotiation). This architecture allows Fedify and your Hono
|
|
36
|
+
application to coexist in the same domain and port.
|
|
37
|
+
|
|
38
|
+
For example, if you make a request to */.well-known/webfinger* Fedify will
|
|
39
|
+
handle the request by itself, but if you make a request to */users/alice*
|
|
40
|
+
(assuming your Hono app has a handler for `/users/:handle`) with `Accept:
|
|
41
|
+
text/html` header, Fedify will dispatch the request to the Hono app's
|
|
42
|
+
appropriate handler for `/users/:handle`. Or if you define an actor dispatcher
|
|
43
|
+
for `/users/{handle}` in Fedify, and the request is made with `Accept:
|
|
44
|
+
application/activity+json` header, Fedify will dispatch the request to the
|
|
45
|
+
appropriate actor dispatcher.
|
|
46
|
+
|
|
47
|
+
Installation
|
|
48
|
+
------------
|
|
49
|
+
|
|
50
|
+
~~~~ sh
|
|
51
|
+
deno add jsr:@fedify/hono # Deno
|
|
52
|
+
npm add @fedify/hono # npm
|
|
53
|
+
pnpm add @fedify/hono # pnpm
|
|
54
|
+
yarn add @fedify/hono # Yarn
|
|
55
|
+
bun add @fedify/hono # Bun
|
|
56
|
+
~~~~
|
|
57
|
+
|
|
58
|
+
[JSR]: https://jsr.io/@fedify/hono
|
|
59
|
+
[JSR badge]: https://jsr.io/badges/@fedify/hono
|
|
60
|
+
[npm]: https://www.npmjs.com/package/@fedify/hono
|
|
61
|
+
[npm badge]: https://img.shields.io/npm/v/@fedify/hono?logo=npm
|
|
62
|
+
[@fedify@hollo.social badge]: https://fedi-badge.deno.dev/@fedify@hollo.social/followers.svg
|
|
63
|
+
[@fedify@hollo.social]: https://hollo.social/@fedify
|
|
64
|
+
[Fedify]: https://fedify.dev/
|
|
65
|
+
[Hono]: https://hono.dev/
|
package/dist/mod.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ type HonoMiddleware<THonoContext extends HonoContext> = (ctx: THonoContext, next
|
|
|
19
19
|
* @template THonoContext A type of the Hono context.
|
|
20
20
|
* @param context A Hono context object.
|
|
21
21
|
* @returns A context data for the {@link Federation} object.
|
|
22
|
+
* @since 1.9.0
|
|
22
23
|
*/
|
|
23
24
|
type ContextDataFactory<TContextData, THonoContext> = (context: THonoContext) => TContextData | Promise<TContextData>;
|
|
24
25
|
/**
|
|
@@ -31,6 +32,7 @@ type ContextDataFactory<TContextData, THonoContext> = (context: THonoContext) =>
|
|
|
31
32
|
* @param contextDataFactory A function to create a context data for the
|
|
32
33
|
* {@link Federation} object.
|
|
33
34
|
* @returns A Hono middleware.
|
|
35
|
+
* @since 1.9.0
|
|
34
36
|
*/
|
|
35
37
|
declare function federation<TContextData, THonoContext extends HonoContext>(federation: Federation<TContextData>, contextDataFactory: ContextDataFactory<TContextData, THonoContext>): HonoMiddleware<THonoContext>;
|
|
36
38
|
//#endregion
|
package/dist/mod.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/hono",
|
|
3
|
-
"version": "1.9.0-pr.388.
|
|
3
|
+
"version": "1.9.0-pr.388.1457+92d31874",
|
|
4
4
|
"description": "Integrate Fedify with Hono",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Fedify",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
],
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"hono": "^4.0.0",
|
|
55
|
-
"@fedify/fedify": "1.9.0-pr.388.
|
|
55
|
+
"@fedify/fedify": "1.9.0-pr.388.1457+92d31874"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"tsdown": "^0.12.9",
|