@fedify/express 2.5.0-dev.2370 → 2.5.0-dev.2378

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 CHANGED
@@ -6,9 +6,10 @@ function integrateFederation(federation, contextDataFactory) {
6
6
  const body = req.method === "GET" || req.method === "HEAD" ? void 0 : createRequestBody(req);
7
7
  const request = fromERequest(req, body?.stream);
8
8
  const contextData = contextDataFactory(req);
9
- (contextData instanceof Promise ? contextData : Promise.resolve(contextData)).then(async (contextData) => {
10
- let notFound = false;
11
- let notAcceptable = false;
9
+ const contextDataPromise = contextData instanceof Promise ? contextData : Promise.resolve(contextData);
10
+ let notFound = false;
11
+ let notAcceptable = false;
12
+ contextDataPromise.then(async (contextData) => {
12
13
  const response = await federation.fetch(request, {
13
14
  contextData,
14
15
  onNotFound: () => {
@@ -39,6 +40,9 @@ function integrateFederation(federation, contextDataFactory) {
39
40
  res.json = () => res;
40
41
  res.removeHeader = () => res;
41
42
  res.setHeader = () => res;
43
+ }).catch((error) => {
44
+ if (notFound || notAcceptable) throw error;
45
+ next(error === "route" || error === "router" ? new Error(error) : error || /* @__PURE__ */ new Error("The federation middleware promise was rejected."));
42
46
  });
43
47
  };
44
48
  }
package/dist/index.js CHANGED
@@ -5,9 +5,10 @@ function integrateFederation(federation, contextDataFactory) {
5
5
  const body = req.method === "GET" || req.method === "HEAD" ? void 0 : createRequestBody(req);
6
6
  const request = fromERequest(req, body?.stream);
7
7
  const contextData = contextDataFactory(req);
8
- (contextData instanceof Promise ? contextData : Promise.resolve(contextData)).then(async (contextData) => {
9
- let notFound = false;
10
- let notAcceptable = false;
8
+ const contextDataPromise = contextData instanceof Promise ? contextData : Promise.resolve(contextData);
9
+ let notFound = false;
10
+ let notAcceptable = false;
11
+ contextDataPromise.then(async (contextData) => {
11
12
  const response = await federation.fetch(request, {
12
13
  contextData,
13
14
  onNotFound: () => {
@@ -38,6 +39,9 @@ function integrateFederation(federation, contextDataFactory) {
38
39
  res.json = () => res;
39
40
  res.removeHeader = () => res;
40
41
  res.setHeader = () => res;
42
+ }).catch((error) => {
43
+ if (notFound || notAcceptable) throw error;
44
+ next(error === "route" || error === "router" ? new Error(error) : error || /* @__PURE__ */ new Error("The federation middleware promise was rejected."));
41
45
  });
42
46
  };
43
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/express",
3
- "version": "2.5.0-dev.2370+e0cfd033",
3
+ "version": "2.5.0-dev.2378+fea9c751",
4
4
  "description": "Integrate Fedify with Express",
5
5
  "keywords": [
6
6
  "Fedify",
@@ -46,7 +46,7 @@
46
46
  ],
47
47
  "peerDependencies": {
48
48
  "express": ">=4.0.0",
49
- "@fedify/fedify": "^2.5.0-dev.2370+e0cfd033"
49
+ "@fedify/fedify": "^2.5.0-dev.2378+fea9c751"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/express": "^4.0.0",