better-call 1.0.7 → 1.0.8
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 +12 -3
- 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 +12 -3
- package/dist/index.js.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/{router-mvPUuWw_.d.cts → router-Bn_wF2y_.d.cts} +7 -0
- package/dist/{router-mvPUuWw_.d.ts → router-Bn_wF2y_.d.ts} +7 -0
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as APIError, k as CookieOptions, C as CookiePrefixOptions, b as Endpoint, a as EndpointContext, E as EndpointOptions, H as HTTPMethod, U as HasRequiredKeys, t as InferBody, I as InferBodyInput, F as InferHeaders, G as InferHeadersInput, x as InferInputMethod, w as InferMethod, K as InferMiddlewareBody, L as InferMiddlewareQuery, y as InferParam, z as InferParamInput, Z as InferParamPath, $ as InferParamWildCard, v as InferQuery, u as InferQueryInput, B as InferRequest, D as InferRequestInput, J as InferUse, N as InputContext, W as IsEmptyObject, Y as MergeObject, r as Method, h as Middleware, e as MiddlewareContext, g as MiddlewareInputContext, M as MiddlewareOptions, d as MiddlewareResponse, n as OpenAPIParameter, O as OpenAPISchemaType, P as Path, V as Prettify, T as RequiredKeysOf, j as Router, R as RouterConfig, a0 as StandardSchemaV1, S as Status, X as UnionToIntersection, _ as _statusCode, c as createEndpoint, Q as createInternalContext, f as createMiddleware, i as createRouter, o as generator, l as getCookieKey, q as getHTML, p as parseCookies, s as serializeCookie, m as serializeSignedCookie } from './router-
|
|
1
|
+
export { A as APIError, k as CookieOptions, C as CookiePrefixOptions, b as Endpoint, a as EndpointContext, E as EndpointOptions, H as HTTPMethod, U as HasRequiredKeys, t as InferBody, I as InferBodyInput, F as InferHeaders, G as InferHeadersInput, x as InferInputMethod, w as InferMethod, K as InferMiddlewareBody, L as InferMiddlewareQuery, y as InferParam, z as InferParamInput, Z as InferParamPath, $ as InferParamWildCard, v as InferQuery, u as InferQueryInput, B as InferRequest, D as InferRequestInput, J as InferUse, N as InputContext, W as IsEmptyObject, Y as MergeObject, r as Method, h as Middleware, e as MiddlewareContext, g as MiddlewareInputContext, M as MiddlewareOptions, d as MiddlewareResponse, n as OpenAPIParameter, O as OpenAPISchemaType, P as Path, V as Prettify, T as RequiredKeysOf, j as Router, R as RouterConfig, a0 as StandardSchemaV1, S as Status, X as UnionToIntersection, _ as _statusCode, c as createEndpoint, Q as createInternalContext, f as createMiddleware, i as createRouter, o as generator, l as getCookieKey, q as getHTML, p as parseCookies, s as serializeCookie, m as serializeSignedCookie } from './router-Bn_wF2y_.cjs';
|
|
2
2
|
|
|
3
3
|
declare function toResponse(data?: any, init?: ResponseInit): Response;
|
|
4
4
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as APIError, k as CookieOptions, C as CookiePrefixOptions, b as Endpoint, a as EndpointContext, E as EndpointOptions, H as HTTPMethod, U as HasRequiredKeys, t as InferBody, I as InferBodyInput, F as InferHeaders, G as InferHeadersInput, x as InferInputMethod, w as InferMethod, K as InferMiddlewareBody, L as InferMiddlewareQuery, y as InferParam, z as InferParamInput, Z as InferParamPath, $ as InferParamWildCard, v as InferQuery, u as InferQueryInput, B as InferRequest, D as InferRequestInput, J as InferUse, N as InputContext, W as IsEmptyObject, Y as MergeObject, r as Method, h as Middleware, e as MiddlewareContext, g as MiddlewareInputContext, M as MiddlewareOptions, d as MiddlewareResponse, n as OpenAPIParameter, O as OpenAPISchemaType, P as Path, V as Prettify, T as RequiredKeysOf, j as Router, R as RouterConfig, a0 as StandardSchemaV1, S as Status, X as UnionToIntersection, _ as _statusCode, c as createEndpoint, Q as createInternalContext, f as createMiddleware, i as createRouter, o as generator, l as getCookieKey, q as getHTML, p as parseCookies, s as serializeCookie, m as serializeSignedCookie } from './router-
|
|
1
|
+
export { A as APIError, k as CookieOptions, C as CookiePrefixOptions, b as Endpoint, a as EndpointContext, E as EndpointOptions, H as HTTPMethod, U as HasRequiredKeys, t as InferBody, I as InferBodyInput, F as InferHeaders, G as InferHeadersInput, x as InferInputMethod, w as InferMethod, K as InferMiddlewareBody, L as InferMiddlewareQuery, y as InferParam, z as InferParamInput, Z as InferParamPath, $ as InferParamWildCard, v as InferQuery, u as InferQueryInput, B as InferRequest, D as InferRequestInput, J as InferUse, N as InputContext, W as IsEmptyObject, Y as MergeObject, r as Method, h as Middleware, e as MiddlewareContext, g as MiddlewareInputContext, M as MiddlewareOptions, d as MiddlewareResponse, n as OpenAPIParameter, O as OpenAPISchemaType, P as Path, V as Prettify, T as RequiredKeysOf, j as Router, R as RouterConfig, a0 as StandardSchemaV1, S as Status, X as UnionToIntersection, _ as _statusCode, c as createEndpoint, Q as createInternalContext, f as createMiddleware, i as createRouter, o as generator, l as getCookieKey, q as getHTML, p as parseCookies, s as serializeCookie, m as serializeSignedCookie } from './router-Bn_wF2y_.js';
|
|
2
2
|
|
|
3
3
|
declare function toResponse(data?: any, init?: ResponseInit): Response;
|
|
4
4
|
|
package/dist/index.js
CHANGED
|
@@ -170,6 +170,9 @@ function toResponse(data, init) {
|
|
|
170
170
|
let body = data;
|
|
171
171
|
let headers = new Headers(init?.headers);
|
|
172
172
|
if (!data) {
|
|
173
|
+
if (data === null) {
|
|
174
|
+
body = JSON.stringify(null);
|
|
175
|
+
}
|
|
173
176
|
headers.set("content-type", "application/json");
|
|
174
177
|
} else if (typeof data === "string") {
|
|
175
178
|
body = data;
|
|
@@ -565,9 +568,15 @@ var createEndpoint2 = (path, options, handler) => {
|
|
|
565
568
|
options,
|
|
566
569
|
path
|
|
567
570
|
});
|
|
568
|
-
const response = await handler(internalContext).catch((e) => {
|
|
569
|
-
if (isAPIError(e)
|
|
570
|
-
|
|
571
|
+
const response = await handler(internalContext).catch(async (e) => {
|
|
572
|
+
if (isAPIError(e)) {
|
|
573
|
+
const onAPIError = options.onAPIError;
|
|
574
|
+
if (onAPIError) {
|
|
575
|
+
await onAPIError(e);
|
|
576
|
+
}
|
|
577
|
+
if (context.asResponse) {
|
|
578
|
+
return e;
|
|
579
|
+
}
|
|
571
580
|
}
|
|
572
581
|
throw e;
|
|
573
582
|
});
|