@fedify/elysia 2.0.0-dev.1566 → 2.0.0-dev.158

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright 2024–2025 Hong Minhee
3
+ Copyright 2024–2026 Hong Minhee
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
package/dist/index.cjs ADDED
@@ -0,0 +1,37 @@
1
+
2
+ //#region src/index.ts
3
+ const fedify = (federation, contextDataFactory) => {
4
+ return (app) => app.decorate("federation", federation).onRequest(async ({ request, set, federation: federation$1 }) => {
5
+ let notFound = false;
6
+ let notAcceptable = false;
7
+ const contextData = await contextDataFactory(request);
8
+ const response = await federation$1.fetch(request, {
9
+ contextData,
10
+ onNotFound: () => {
11
+ notFound = true;
12
+ return new Response("Not found", { status: 404 });
13
+ },
14
+ onNotAcceptable: () => {
15
+ notAcceptable = true;
16
+ return new Response("Not acceptable", {
17
+ status: 406,
18
+ headers: {
19
+ "Content-Type": "text/plain",
20
+ Vary: "Accept"
21
+ }
22
+ });
23
+ }
24
+ });
25
+ if (!notFound && !notAcceptable) {
26
+ set.status = response.status;
27
+ response.headers.forEach((value, key) => {
28
+ set.headers[key] = value;
29
+ });
30
+ if (response.body) return response;
31
+ return new Response(null, { status: response.status });
32
+ }
33
+ }).as("global");
34
+ };
35
+
36
+ //#endregion
37
+ exports.fedify = fedify;
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/elysia",
3
- "version": "2.0.0-dev.1566+4a3d567d",
3
+ "version": "2.0.0-dev.158+628cd89e",
4
4
  "description": "Integrate Fedify with Elysia",
5
5
  "keywords": [
6
6
  "Fedify",
@@ -26,14 +26,18 @@
26
26
  ],
27
27
  "type": "module",
28
28
  "module": "./dist/index.js",
29
+ "main": "./dist/index.cjs",
29
30
  "types": "./dist/index.d.ts",
30
31
  "exports": {
31
32
  ".": {
32
- "import": {
33
- "types": "./dist/index.d.ts",
34
- "import": "./dist/index.js",
35
- "default": "./dist/index.js"
36
- }
33
+ "types": {
34
+ "import": "./dist/index.d.ts",
35
+ "require": "./dist/index.d.cts",
36
+ "default": "./dist/index.d.ts"
37
+ },
38
+ "import": "./dist/index.js",
39
+ "require": "./dist/index.cjs",
40
+ "default": "./dist/index.js"
37
41
  },
38
42
  "./package.json": "./package.json"
39
43
  },
@@ -43,12 +47,12 @@
43
47
  ],
44
48
  "peerDependencies": {
45
49
  "elysia": "^1.3.6",
46
- "@fedify/fedify": "2.0.0-dev.1566+4a3d567d"
50
+ "@fedify/fedify": "^2.0.0-dev.158+628cd89e"
47
51
  },
48
52
  "devDependencies": {
49
53
  "bun-types": "^1.2.19",
50
54
  "tsdown": "^0.12.9",
51
- "typescript": "^5.9.2"
55
+ "typescript": "^5.9.3"
52
56
  },
53
57
  "scripts": {
54
58
  "build": "tsdown",