better-call 1.0.25-beta.3 → 1.0.26-beta.1
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/README.md +38 -1
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/index.cjs +20 -2
- 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 +20 -2
- package/dist/index.js.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/{router-CC_up1_c.d.ts → router-BH6Wndse.d.ts} +48 -4
- package/dist/{router-DOTL_ENw.d.cts → router-CeSGPJlX.d.cts} +48 -4
- package/package.json +2 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APIError, BetterCallError, CookieOptions, CookiePrefixOptions, Endpoint, EndpointBaseOptions, EndpointBodyMethodOptions, EndpointContext, EndpointOptions, HTTPMethod, HasRequiredKeys, InferBody, InferBodyInput, InferHeaders, InferHeadersInput, InferInputMethod, InferMethod, InferMiddlewareBody, InferMiddlewareQuery, InferParam, InferParamInput, InferParamPath, InferParamWildCard, InferQuery, InferQueryInput, InferRequest, InferRequestInput, InferUse, InputContext, IsEmptyObject, MergeObject, Method, Middleware, MiddlewareContext, MiddlewareInputContext, MiddlewareOptions, MiddlewareResponse, OpenAPIParameter, OpenAPISchemaType, Path, Prettify, RequiredKeysOf, Router, RouterConfig, StandardSchemaV1, Status, StrictEndpoint, UnionToIntersection, _statusCode, createEndpoint, createInternalContext, createMiddleware, createRouter, generator, getCookieKey, getHTML, hideInternalStackFrames, makeErrorForHideStackFrame, parseCookies, serializeCookie, serializeSignedCookie } from "./router-
|
|
1
|
+
import { APIError, BetterCallError, CookieOptions, CookiePrefixOptions, Endpoint, EndpointBaseOptions, EndpointBodyMethodOptions, EndpointContext, EndpointOptions, HTTPMethod, HasRequiredKeys, InferBody, InferBodyInput, InferHeaders, InferHeadersInput, InferInputMethod, InferMethod, InferMiddlewareBody, InferMiddlewareQuery, InferParam, InferParamInput, InferParamPath, InferParamWildCard, InferQuery, InferQueryInput, InferRequest, InferRequestInput, InferUse, InputContext, IsEmptyObject, MergeObject, Method, Middleware, MiddlewareContext, MiddlewareInputContext, MiddlewareOptions, MiddlewareResponse, OpenAPIParameter, OpenAPISchemaType, Path, Prettify, RequiredKeysOf, Router, RouterConfig, StandardSchemaV1, Status, StrictEndpoint, UnionToIntersection, _statusCode, createEndpoint, createInternalContext, createMiddleware, createRouter, generator, getCookieKey, getHTML, hideInternalStackFrames, makeErrorForHideStackFrame, parseCookies, serializeCookie, serializeSignedCookie } from "./router-CeSGPJlX.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/to-response.d.ts
|
|
4
4
|
type JSONResponse = {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APIError, BetterCallError, CookieOptions, CookiePrefixOptions, Endpoint, EndpointBaseOptions, EndpointBodyMethodOptions, EndpointContext, EndpointOptions, HTTPMethod, HasRequiredKeys, InferBody, InferBodyInput, InferHeaders, InferHeadersInput, InferInputMethod, InferMethod, InferMiddlewareBody, InferMiddlewareQuery, InferParam, InferParamInput, InferParamPath, InferParamWildCard, InferQuery, InferQueryInput, InferRequest, InferRequestInput, InferUse, InputContext, IsEmptyObject, MergeObject, Method, Middleware, MiddlewareContext, MiddlewareInputContext, MiddlewareOptions, MiddlewareResponse, OpenAPIParameter, OpenAPISchemaType, Path, Prettify, RequiredKeysOf, Router, RouterConfig, StandardSchemaV1, Status, StrictEndpoint, UnionToIntersection, _statusCode, createEndpoint, createInternalContext, createMiddleware, createRouter, generator, getCookieKey, getHTML, hideInternalStackFrames, makeErrorForHideStackFrame, parseCookies, serializeCookie, serializeSignedCookie } from "./router-
|
|
1
|
+
import { APIError, BetterCallError, CookieOptions, CookiePrefixOptions, Endpoint, EndpointBaseOptions, EndpointBodyMethodOptions, EndpointContext, EndpointOptions, HTTPMethod, HasRequiredKeys, InferBody, InferBodyInput, InferHeaders, InferHeadersInput, InferInputMethod, InferMethod, InferMiddlewareBody, InferMiddlewareQuery, InferParam, InferParamInput, InferParamPath, InferParamWildCard, InferQuery, InferQueryInput, InferRequest, InferRequestInput, InferUse, InputContext, IsEmptyObject, MergeObject, Method, Middleware, MiddlewareContext, MiddlewareInputContext, MiddlewareOptions, MiddlewareResponse, OpenAPIParameter, OpenAPISchemaType, Path, Prettify, RequiredKeysOf, Router, RouterConfig, StandardSchemaV1, Status, StrictEndpoint, UnionToIntersection, _statusCode, createEndpoint, createInternalContext, createMiddleware, createRouter, generator, getCookieKey, getHTML, hideInternalStackFrames, makeErrorForHideStackFrame, parseCookies, serializeCookie, serializeSignedCookie } from "./router-BH6Wndse.js";
|
|
2
2
|
|
|
3
3
|
//#region src/to-response.d.ts
|
|
4
4
|
type JSONResponse = {
|
package/dist/index.js
CHANGED
|
@@ -414,6 +414,7 @@ const serializeSignedCookie = async (key, value, secret, opt) => {
|
|
|
414
414
|
//#region src/context.ts
|
|
415
415
|
const createInternalContext = async (context, { options, path }) => {
|
|
416
416
|
const headers = new Headers();
|
|
417
|
+
let responseStatus = void 0;
|
|
417
418
|
const { data, error } = await runValidation(options, context);
|
|
418
419
|
if (error) throw new APIError(400, {
|
|
419
420
|
message: error.message,
|
|
@@ -474,6 +475,9 @@ const createInternalContext = async (context, { options, path }) => {
|
|
|
474
475
|
error: (status, body, headers$1) => {
|
|
475
476
|
return new APIError(status, body, headers$1);
|
|
476
477
|
},
|
|
478
|
+
setStatus: (status) => {
|
|
479
|
+
responseStatus = status;
|
|
480
|
+
},
|
|
477
481
|
json: (json, routerResponse) => {
|
|
478
482
|
if (!context.asResponse) return json;
|
|
479
483
|
return {
|
|
@@ -482,7 +486,10 @@ const createInternalContext = async (context, { options, path }) => {
|
|
|
482
486
|
_flag: "json"
|
|
483
487
|
};
|
|
484
488
|
},
|
|
485
|
-
responseHeaders: headers
|
|
489
|
+
responseHeaders: headers,
|
|
490
|
+
get responseStatus() {
|
|
491
|
+
return responseStatus;
|
|
492
|
+
}
|
|
486
493
|
};
|
|
487
494
|
for (const middleware of options.use || []) {
|
|
488
495
|
const response = await middleware({
|
|
@@ -520,9 +527,20 @@ const createEndpoint = (path, options, handler) => {
|
|
|
520
527
|
throw e;
|
|
521
528
|
});
|
|
522
529
|
const headers = internalContext.responseHeaders;
|
|
523
|
-
|
|
530
|
+
const status = internalContext.responseStatus;
|
|
531
|
+
return context.asResponse ? toResponse(response, {
|
|
532
|
+
headers,
|
|
533
|
+
status
|
|
534
|
+
}) : context.returnHeaders ? context.returnStatus ? {
|
|
535
|
+
headers,
|
|
536
|
+
response,
|
|
537
|
+
status
|
|
538
|
+
} : {
|
|
524
539
|
headers,
|
|
525
540
|
response
|
|
541
|
+
} : context.returnStatus ? {
|
|
542
|
+
response,
|
|
543
|
+
status
|
|
526
544
|
} : response;
|
|
527
545
|
};
|
|
528
546
|
internalHandler.options = options;
|