better-call 1.0.19 → 1.0.20
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/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/index.cjs +11 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/router-BDQGRZdc.d.cts +2816 -0
- package/dist/router-BDQGRZdc.d.ts +2816 -0
- package/package.json +1 -1
- package/dist/router-DcqXHY8X.d.cts +0 -1285
- package/dist/router-DcqXHY8X.d.ts +0 -1285
package/dist/client.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BetterFetchOption, BetterFetchResponse } from '@better-fetch/fetch';
|
|
2
|
-
import { j as Router, Z as UnionToIntersection, b as Endpoint, W as HasRequiredKeys } from './router-
|
|
2
|
+
import { j as Router, Z as UnionToIntersection, b as Endpoint, W as HasRequiredKeys } from './router-BDQGRZdc.cjs';
|
|
3
3
|
|
|
4
4
|
type HasRequired<T extends {
|
|
5
5
|
body?: any;
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BetterFetchOption, BetterFetchResponse } from '@better-fetch/fetch';
|
|
2
|
-
import { j as Router, Z as UnionToIntersection, b as Endpoint, W as HasRequiredKeys } from './router-
|
|
2
|
+
import { j as Router, Z as UnionToIntersection, b as Endpoint, W as HasRequiredKeys } from './router-BDQGRZdc.js';
|
|
3
3
|
|
|
4
4
|
type HasRequired<T extends {
|
|
5
5
|
body?: any;
|
package/dist/index.cjs
CHANGED
|
@@ -700,6 +700,7 @@ createMiddleware.create = (opts) => {
|
|
|
700
700
|
};
|
|
701
701
|
|
|
702
702
|
// src/endpoint.ts
|
|
703
|
+
var originalHandlerSymbol = Symbol("kOriginalHandler");
|
|
703
704
|
var createEndpoint2 = (path, options, handler) => {
|
|
704
705
|
const internalHandler = async (...inputCtx) => {
|
|
705
706
|
const context = inputCtx[0] || {};
|
|
@@ -707,7 +708,9 @@ var createEndpoint2 = (path, options, handler) => {
|
|
|
707
708
|
options,
|
|
708
709
|
path
|
|
709
710
|
});
|
|
710
|
-
const response = await
|
|
711
|
+
const response = await internalHandler[originalHandlerSymbol](
|
|
712
|
+
internalContext
|
|
713
|
+
).catch(async (e) => {
|
|
711
714
|
if (isAPIError(e)) {
|
|
712
715
|
const onAPIError = options.onAPIError;
|
|
713
716
|
if (onAPIError) {
|
|
@@ -727,6 +730,13 @@ var createEndpoint2 = (path, options, handler) => {
|
|
|
727
730
|
response
|
|
728
731
|
} : response;
|
|
729
732
|
};
|
|
733
|
+
internalHandler[originalHandlerSymbol] = handler;
|
|
734
|
+
internalHandler.wrap = (fn) => {
|
|
735
|
+
const wrappedFn = async (context) => {
|
|
736
|
+
return fn(context, internalHandler[originalHandlerSymbol]);
|
|
737
|
+
};
|
|
738
|
+
return createEndpoint2(path, options, wrappedFn);
|
|
739
|
+
};
|
|
730
740
|
internalHandler.options = options;
|
|
731
741
|
internalHandler.path = path;
|
|
732
742
|
return internalHandler;
|