better-call 1.0.27 → 1.0.28-beta.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/node.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { Router } from "./router-DxWRTWmk.cjs";
1
+ import { Router } from "./router-rGV6mTr8.cjs";
2
2
  import { IncomingMessage, ServerResponse } from "node:http";
3
3
 
4
4
  //#region src/adapters/node/request.d.ts
package/dist/node.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Router } from "./router-D1f_-c2B.js";
1
+ import { Router } from "./router-NaFkuy-s.js";
2
2
  import { IncomingMessage, ServerResponse } from "node:http";
3
3
 
4
4
  //#region src/adapters/node/request.d.ts
@@ -931,6 +931,22 @@ interface EndpointBaseOptions {
931
931
  * If enabled, endpoint won't be exposed over a router
932
932
  */
933
933
  SERVER_ONLY?: boolean;
934
+ /**
935
+ * List of allowed media types (MIME types) for the endpoint
936
+ *
937
+ * if provided, only the media types in the list will be allowed to be passed in the body
938
+ *
939
+ * @example
940
+ * ```ts
941
+ * const endpoint = createEndpoint("/path", {
942
+ * method: "POST",
943
+ * allowedMediaTypes: ["application/json", "application/x-www-form-urlencoded"],
944
+ * }, async(ctx)=>{
945
+ * const body = ctx.body
946
+ * })
947
+ * ```
948
+ */
949
+ allowedMediaTypes?: string[];
934
950
  /**
935
951
  * Extra metadata
936
952
  */
@@ -1210,6 +1226,20 @@ interface RouterConfig {
1210
1226
  * A callback to run before any request
1211
1227
  */
1212
1228
  onRequest?: (req: Request) => any | Promise<any>;
1229
+ /**
1230
+ * List of allowed media types (MIME types) for the router
1231
+ *
1232
+ * if provided, only the media types in the list will be allowed to be passed in the body.
1233
+ *
1234
+ * If an endpoint has allowed media types, it will override the router's allowed media types.
1235
+ *
1236
+ * @example
1237
+ * ```ts
1238
+ * const router = createRouter({
1239
+ * allowedMediaTypes: ["application/json", "application/x-www-form-urlencoded"],
1240
+ * })
1241
+ */
1242
+ allowedMediaTypes?: string[];
1213
1243
  /**
1214
1244
  * Open API route configuration
1215
1245
  */
@@ -1260,4 +1290,4 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
1260
1290
  type Router = ReturnType<typeof createRouter>;
1261
1291
  //#endregion
1262
1292
  export { 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$1 as Path, Prettify, RequiredKeysOf, Router, RouterConfig, StandardSchemaV1, Status, StrictEndpoint, UnionToIntersection, createEndpoint, createInternalContext, createMiddleware, createRouter, generator, getCookieKey, getHTML, hideInternalStackFrames, makeErrorForHideStackFrame, parseCookies, serializeCookie, serializeSignedCookie, statusCodes };
1263
- //# sourceMappingURL=router-D1f_-c2B.d.ts.map
1293
+ //# sourceMappingURL=router-NaFkuy-s.d.ts.map
@@ -931,6 +931,22 @@ interface EndpointBaseOptions {
931
931
  * If enabled, endpoint won't be exposed over a router
932
932
  */
933
933
  SERVER_ONLY?: boolean;
934
+ /**
935
+ * List of allowed media types (MIME types) for the endpoint
936
+ *
937
+ * if provided, only the media types in the list will be allowed to be passed in the body
938
+ *
939
+ * @example
940
+ * ```ts
941
+ * const endpoint = createEndpoint("/path", {
942
+ * method: "POST",
943
+ * allowedMediaTypes: ["application/json", "application/x-www-form-urlencoded"],
944
+ * }, async(ctx)=>{
945
+ * const body = ctx.body
946
+ * })
947
+ * ```
948
+ */
949
+ allowedMediaTypes?: string[];
934
950
  /**
935
951
  * Extra metadata
936
952
  */
@@ -1210,6 +1226,20 @@ interface RouterConfig {
1210
1226
  * A callback to run before any request
1211
1227
  */
1212
1228
  onRequest?: (req: Request) => any | Promise<any>;
1229
+ /**
1230
+ * List of allowed media types (MIME types) for the router
1231
+ *
1232
+ * if provided, only the media types in the list will be allowed to be passed in the body.
1233
+ *
1234
+ * If an endpoint has allowed media types, it will override the router's allowed media types.
1235
+ *
1236
+ * @example
1237
+ * ```ts
1238
+ * const router = createRouter({
1239
+ * allowedMediaTypes: ["application/json", "application/x-www-form-urlencoded"],
1240
+ * })
1241
+ */
1242
+ allowedMediaTypes?: string[];
1213
1243
  /**
1214
1244
  * Open API route configuration
1215
1245
  */
@@ -1260,4 +1290,4 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
1260
1290
  type Router = ReturnType<typeof createRouter>;
1261
1291
  //#endregion
1262
1292
  export { 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$1 as Path, Prettify, RequiredKeysOf, Router, RouterConfig, StandardSchemaV1, Status, StrictEndpoint, UnionToIntersection, createEndpoint, createInternalContext, createMiddleware, createRouter, generator, getCookieKey, getHTML, hideInternalStackFrames, makeErrorForHideStackFrame, parseCookies, serializeCookie, serializeSignedCookie, statusCodes };
1263
- //# sourceMappingURL=router-DxWRTWmk.d.cts.map
1293
+ //# sourceMappingURL=router-rGV6mTr8.d.cts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-call",
3
- "version": "1.0.27",
3
+ "version": "1.0.28-beta.2",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",