@relai-fi/x402 0.6.0-rc.0 → 0.6.0-rc.2
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 +28 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -6
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +28 -6
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +28 -6
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -860,12 +860,34 @@ var Relai = class {
|
|
|
860
860
|
path: req.path || req.originalUrl || "/",
|
|
861
861
|
method: (req.method || "GET").toUpperCase()
|
|
862
862
|
};
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
863
|
+
const pluginsWithHook = self.plugins.filter((p) => !!p.afterSettled);
|
|
864
|
+
if (pluginsWithHook.length > 0) {
|
|
865
|
+
const originalJson = res.json?.bind(res);
|
|
866
|
+
const originalSend = res.send?.bind(res);
|
|
867
|
+
let afterSettledFired = false;
|
|
868
|
+
const fireAfterSettled = (statusCode) => {
|
|
869
|
+
if (afterSettledFired) return;
|
|
870
|
+
afterSettledFired = true;
|
|
871
|
+
const resultWithStatus = { ...result, statusCode };
|
|
872
|
+
for (const plugin of pluginsWithHook) {
|
|
873
|
+
plugin.afterSettled(req, resultWithStatus, settleCtx).catch((e) => {
|
|
874
|
+
console.warn(`[Relai] Plugin '${plugin.name}' afterSettled error (non-blocking):`, e);
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
};
|
|
878
|
+
if (typeof originalJson === "function") {
|
|
879
|
+
res.json = function(body) {
|
|
880
|
+
fireAfterSettled(res.statusCode ?? 200);
|
|
881
|
+
res.json = originalJson;
|
|
882
|
+
return originalJson(body);
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
if (typeof originalSend === "function") {
|
|
886
|
+
res.send = function(body) {
|
|
887
|
+
fireAfterSettled(res.statusCode ?? 200);
|
|
888
|
+
res.send = originalSend;
|
|
889
|
+
return originalSend(body);
|
|
890
|
+
};
|
|
869
891
|
}
|
|
870
892
|
}
|
|
871
893
|
}
|