@fedify/elysia 1.8.1-pr.339.1301

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 ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright 2024–2025 Hong Minhee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ <!-- deno-fmt-ignore-file -->
2
+
3
+ @fedify/express: Integrate Fedify with Express
4
+ ==============================================
5
+
6
+ [![npm][npm badge]][npm]
7
+ [![Matrix][Matrix badge]][Matrix]
8
+ [![Follow @fedify@hollo.social][@fedify@hollo.social badge]][@fedify@hollo.social]
9
+
10
+ This package provides a simple way to integrate [Fedify] with [Express].
11
+
12
+ The integration code looks like this:
13
+
14
+ ~~~~ typescript
15
+ import { fedify } from "@fedify/elysia";
16
+ import { federation } from "./federation.ts"; // Your `Federation` instance
17
+ import { Elysia } from "elysia";
18
+
19
+ const app = new Elysia();
20
+
21
+ app
22
+ .use(fedify(federation, () => "context data goes here"))
23
+ .listen(3000);
24
+
25
+ console.log("Elysia App Start!");
26
+ ~~~~
27
+
28
+ [npm]: https://www.npmjs.com/package/@fedify/elysia
29
+ [npm badge]: https://img.shields.io/npm/v/@fedify/express?logo=npm
30
+ [Matrix]: https://matrix.to/#/#fedify:matrix.org
31
+ [Matrix badge]: https://img.shields.io/matrix/fedify%3Amatrix.org
32
+ [@fedify@hollo.social badge]: https://fedi-badge.deno.dev/@fedify@hollo.social/followers.svg
33
+ [@fedify@hollo.social]: https://hollo.social/@fedify
34
+ [Fedify]: https://fedify.dev/
35
+ [Express]: https://expressjs.com/
@@ -0,0 +1,35 @@
1
+ import * as elysia0 from "elysia";
2
+ import { Elysia } from "elysia";
3
+ import { Federation } from "@fedify/fedify";
4
+
5
+ //#region src/index.d.ts
6
+ type ContextDataFactory<TContextData> = (req?: Request) => TContextData | Promise<TContextData>;
7
+ declare const fedify: <TContextData = unknown>(federation: Federation<TContextData>, contextDataFactory: ContextDataFactory<TContextData>) => (app: Elysia) => Elysia<"", {
8
+ decorator: {
9
+ federation: Federation<TContextData>;
10
+ };
11
+ store: {};
12
+ derive: {};
13
+ resolve: {};
14
+ }, {
15
+ typebox: {};
16
+ error: {};
17
+ }, {
18
+ schema: elysia0.MergeSchema<elysia0.MergeSchema<{}, {}, "">, {}, "">;
19
+ standaloneSchema: {};
20
+ macro: {};
21
+ macroFn: {};
22
+ parser: {};
23
+ }, {}, {
24
+ derive: {};
25
+ resolve: {};
26
+ schema: {};
27
+ standaloneSchema: {};
28
+ }, {
29
+ derive: {};
30
+ resolve: {};
31
+ schema: {};
32
+ standaloneSchema: {};
33
+ }>;
34
+ //#endregion
35
+ export { ContextDataFactory, fedify };
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ //#region src/index.ts
2
+ const fedify = (federation, contextDataFactory) => {
3
+ return (app) => app.decorate("federation", federation).onRequest(async ({ request, set, federation: federation$1 }) => {
4
+ let notFound = false;
5
+ let notAcceptable = false;
6
+ const contextData = await contextDataFactory(request);
7
+ const response = await federation$1.fetch(request, {
8
+ contextData,
9
+ onNotFound: () => {
10
+ notFound = true;
11
+ return new Response("Not found", { status: 404 });
12
+ },
13
+ onNotAcceptable: () => {
14
+ notAcceptable = true;
15
+ return new Response("Not acceptable", {
16
+ status: 406,
17
+ headers: {
18
+ "Content-Type": "text/plain",
19
+ Vary: "Accept"
20
+ }
21
+ });
22
+ }
23
+ });
24
+ if (!notFound && !notAcceptable) {
25
+ set.status = response.status;
26
+ response.headers.forEach((value, key) => {
27
+ set.headers[key] = value;
28
+ });
29
+ if (response.body) return response;
30
+ return new Response(null, { status: response.status });
31
+ }
32
+ }).as("global");
33
+ };
34
+
35
+ //#endregion
36
+ export { fedify };
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@fedify/elysia",
3
+ "version": "1.8.1-pr.339.1301+ddaf0757",
4
+ "description": "Integrate Fedify with Elysia",
5
+ "keywords": [
6
+ "Fedify",
7
+ "Elysia"
8
+ ],
9
+ "author": {
10
+ "name": "Hyeonseo Kim",
11
+ "email": "dodok8@gmail.com"
12
+ },
13
+ "homepage": "https://fedify.dev",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/fedify-dev/fedify.git",
17
+ "directory": "packages/elysia"
18
+ },
19
+ "license": "MIT",
20
+ "bugs": {
21
+ "url": "https://github.com/fedify-dev/fedify/issues"
22
+ },
23
+ "funding": [
24
+ "https://opencollective.com/fedify",
25
+ "https://github.com/sponsors/dahlia"
26
+ ],
27
+ "type": "module",
28
+ "module": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "import": {
33
+ "types": "./dist/index.d.ts",
34
+ "import": "./dist/index.js",
35
+ "default": "./dist/index.js"
36
+ }
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
40
+ "files": [
41
+ "dist/",
42
+ "package.json"
43
+ ],
44
+ "peerDependencies": {
45
+ "elysia": "^1.3.6",
46
+ "@fedify/fedify": "1.8.1-pr.339.1301+ddaf0757"
47
+ },
48
+ "devDependencies": {
49
+ "bun-types": "^1.2.19",
50
+ "tsdown": "^0.12.9",
51
+ "typescript": "^5.8.3"
52
+ },
53
+ "scripts": {
54
+ "build": "tsdown",
55
+ "dev": "bun run --watch example.ts"
56
+ }
57
+ }