balda 0.0.62 → 0.0.63

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/lib/index.d.cts CHANGED
@@ -349,6 +349,12 @@ declare class Request<Params extends Record<string, string> = Record<string, str
349
349
  file(fieldName: string): FormFile | null;
350
350
  get cookies(): Record<string, string>;
351
351
  set cookies(value: Record<string, string>);
352
+ /**
353
+ * Returns cookies when the cookie middleware has populated them, otherwise undefined.
354
+ * Useful for compatibility layers that should not throw when cookies are unavailable.
355
+ * @internal
356
+ */
357
+ getOptionalCookies(): Record<string, string> | undefined;
352
358
  /**
353
359
  * The cookie of the request.
354
360
  * @cookie middleware is required
@@ -362,6 +368,12 @@ declare class Request<Params extends Record<string, string> = Record<string, str
362
368
  timeout?: boolean;
363
369
  get session(): Record<string, any> | undefined;
364
370
  set session(value: Record<string, any> | undefined);
371
+ /**
372
+ * Returns session data when the session middleware has populated it, otherwise undefined.
373
+ * Useful for compatibility layers that should not throw when sessions are unavailable.
374
+ * @internal
375
+ */
376
+ getOptionalSession(): Record<string, any> | undefined;
365
377
  /**
366
378
  * Shared throwing functions to avoid per-instance closure allocation.
367
379
  * @internal
@@ -2304,6 +2316,8 @@ type CorsOptions = {
2304
2316
  methods?: CorsMethods[] | string;
2305
2317
  /**
2306
2318
  * Configures the Access-Control-Allow-Headers CORS header. Defaults to allowing all requested headers.
2319
+ * When omitted, Balda echoes `Access-Control-Request-Headers` on preflight requests.
2320
+ * Set this explicitly to override that default behavior.
2307
2321
  */
2308
2322
  allowedHeaders?: string[] | string;
2309
2323
  /**
@@ -4685,7 +4699,9 @@ declare const cookie: (options?: CookieMiddlewareOptions) => TypedMiddleware<{
4685
4699
  * ⚠️ SECURITY WARNING: By default, this plugin allows ALL origins ('*').
4686
4700
  * For production environments, explicitly configure allowed origins.
4687
4701
  *
4688
- * @param options CORS options (all optional)
4702
+ * @param options CORS options (all optional). Omitted options keep Balda's defaults,
4703
+ * including default methods and echoing `Access-Control-Request-Headers` on preflight
4704
+ * requests unless `allowedHeaders` is explicitly overridden.
4689
4705
  *
4690
4706
  * @example
4691
4707
  * // Development (permissive)
package/lib/index.d.ts CHANGED
@@ -349,6 +349,12 @@ declare class Request<Params extends Record<string, string> = Record<string, str
349
349
  file(fieldName: string): FormFile | null;
350
350
  get cookies(): Record<string, string>;
351
351
  set cookies(value: Record<string, string>);
352
+ /**
353
+ * Returns cookies when the cookie middleware has populated them, otherwise undefined.
354
+ * Useful for compatibility layers that should not throw when cookies are unavailable.
355
+ * @internal
356
+ */
357
+ getOptionalCookies(): Record<string, string> | undefined;
352
358
  /**
353
359
  * The cookie of the request.
354
360
  * @cookie middleware is required
@@ -362,6 +368,12 @@ declare class Request<Params extends Record<string, string> = Record<string, str
362
368
  timeout?: boolean;
363
369
  get session(): Record<string, any> | undefined;
364
370
  set session(value: Record<string, any> | undefined);
371
+ /**
372
+ * Returns session data when the session middleware has populated it, otherwise undefined.
373
+ * Useful for compatibility layers that should not throw when sessions are unavailable.
374
+ * @internal
375
+ */
376
+ getOptionalSession(): Record<string, any> | undefined;
365
377
  /**
366
378
  * Shared throwing functions to avoid per-instance closure allocation.
367
379
  * @internal
@@ -2304,6 +2316,8 @@ type CorsOptions = {
2304
2316
  methods?: CorsMethods[] | string;
2305
2317
  /**
2306
2318
  * Configures the Access-Control-Allow-Headers CORS header. Defaults to allowing all requested headers.
2319
+ * When omitted, Balda echoes `Access-Control-Request-Headers` on preflight requests.
2320
+ * Set this explicitly to override that default behavior.
2307
2321
  */
2308
2322
  allowedHeaders?: string[] | string;
2309
2323
  /**
@@ -4685,7 +4699,9 @@ declare const cookie: (options?: CookieMiddlewareOptions) => TypedMiddleware<{
4685
4699
  * ⚠️ SECURITY WARNING: By default, this plugin allows ALL origins ('*').
4686
4700
  * For production environments, explicitly configure allowed origins.
4687
4701
  *
4688
- * @param options CORS options (all optional)
4702
+ * @param options CORS options (all optional). Omitted options keep Balda's defaults,
4703
+ * including default methods and echoing `Access-Control-Request-Headers` on preflight
4704
+ * requests unless `allowedHeaders` is explicitly overridden.
4689
4705
  *
4690
4706
  * @example
4691
4707
  * // Development (permissive)