@fedify/elysia 2.0.0-dev.1604 → 2.0.0-dev.1641

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/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.1604+23a1ea67",
3
+ "version": "2.0.0-dev.1641+6b0c942c",
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,7 +47,7 @@
43
47
  ],
44
48
  "peerDependencies": {
45
49
  "elysia": "^1.3.6",
46
- "@fedify/fedify": "^2.0.0-dev.1604+23a1ea67"
50
+ "@fedify/fedify": "^2.0.0-dev.1641+6b0c942c"
47
51
  },
48
52
  "devDependencies": {
49
53
  "bun-types": "^1.2.19",