Skip to content

Commit

Permalink
support undefined in http request schema apis (#3136)
Browse files Browse the repository at this point in the history
Co-authored-by: Tim Smart <tim.smart@arisechurch.com>
  • Loading branch information
tim-smart and Tim Smart authored Jul 1, 2024
1 parent a4982f6 commit 7f8900a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-crabs-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/platform": patch
---

support undefined in http request schema apis
6 changes: 3 additions & 3 deletions packages/platform/src/HttpIncomingMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const schemaBodyJsonScoped = <A, I, R>(schema: Schema.Schema<A, I, R>, op
* @since 1.0.0
* @category schema
*/
export const schemaBodyUrlParams = <A, I extends Readonly<Record<string, string>>, R>(
export const schemaBodyUrlParams = <A, I extends Readonly<Record<string, string | undefined>>, R>(
schema: Schema.Schema<A, I, R>,
options?: ParseOptions | undefined
) => {
Expand All @@ -82,7 +82,7 @@ export const schemaBodyUrlParams = <A, I extends Readonly<Record<string, string>
* @since 1.0.0
* @category schema
*/
export const schemaBodyUrlParamsScoped = <A, I extends Readonly<Record<string, string>>, R>(
export const schemaBodyUrlParamsScoped = <A, I extends Readonly<Record<string, string | undefined>>, R>(
schema: Schema.Schema<A, I, R>,
options?: ParseOptions | undefined
) => {
Expand All @@ -109,7 +109,7 @@ export const schemaHeaders = <A, I extends Readonly<Record<string, string | unde
* @since 1.0.0
* @category schema
*/
export const schemaHeadersScoped = <A, I extends Readonly<Record<string, string>>, R>(
export const schemaHeadersScoped = <A, I extends Readonly<Record<string, string | undefined>>, R>(
schema: Schema.Schema<A, I, R>,
options?: ParseOptions | undefined
) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/platform/src/HttpServerRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const upgradeChannel: <IE = never>() => Channel<
* @since 1.0.0
* @category schema
*/
export const schemaCookies: <A, I extends Readonly<Record<string, string>>, R>(
export const schemaCookies: <A, I extends Readonly<Record<string, string | undefined>>, R>(
schema: Schema.Schema<A, I, R>,
options?: ParseOptions | undefined
) => Effect.Effect<A, ParseResult.ParseError, HttpServerRequest | R> = internal.schemaCookies
Expand All @@ -143,7 +143,7 @@ export const schemaCookies: <A, I extends Readonly<Record<string, string>>, R>(
* @since 1.0.0
* @category schema
*/
export const schemaHeaders: <A, I extends Readonly<Record<string, string>>, R>(
export const schemaHeaders: <A, I extends Readonly<Record<string, string | undefined>>, R>(
schema: Schema.Schema<A, I, R>,
options?: ParseOptions | undefined
) => Effect.Effect<A, ParseResult.ParseError, HttpServerRequest | R> = internal.schemaHeaders
Expand Down Expand Up @@ -183,7 +183,7 @@ export const schemaBodyForm: <A, I extends Partial<Multipart.Persisted>, R>(
* @since 1.0.0
* @category schema
*/
export const schemaBodyUrlParams: <A, I extends Readonly<Record<string, string>>, R>(
export const schemaBodyUrlParams: <A, I extends Readonly<Record<string, string | undefined>>, R>(
schema: Schema.Schema<A, I, R>,
options?: ParseOptions | undefined
) => Effect.Effect<A, ParseResult.ParseError | Error.RequestError, R | HttpServerRequest> = internal.schemaBodyUrlParams
Expand Down
6 changes: 3 additions & 3 deletions packages/platform/src/internal/httpServerRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const searchParamsFromURL = (url: URL): ReadonlyRecord<string, string | A
}

/** @internal */
export const schemaCookies = <A, I extends Readonly<Record<string, string>>, R>(
export const schemaCookies = <A, I extends Readonly<Record<string, string | undefined>>, R>(
schema: Schema.Schema<A, I, R>,
options?: ParseOptions | undefined
) => {
Expand All @@ -72,7 +72,7 @@ export const schemaCookies = <A, I extends Readonly<Record<string, string>>, R>(
}

/** @internal */
export const schemaHeaders = <A, I extends Readonly<Record<string, string>>, R>(
export const schemaHeaders = <A, I extends Readonly<Record<string, string | undefined>>, R>(
schema: Schema.Schema<A, I, R>,
options?: ParseOptions | undefined
) => {
Expand Down Expand Up @@ -118,7 +118,7 @@ export const schemaBodyForm = <A, I extends Partial<Multipart.Persisted>, R>(
}

/** @internal */
export const schemaBodyUrlParams = <A, I extends Readonly<Record<string, string>>, R>(
export const schemaBodyUrlParams = <A, I extends Readonly<Record<string, string | undefined>>, R>(
schema: Schema.Schema<A, I, R>,
options?: ParseOptions | undefined
) => {
Expand Down

0 comments on commit 7f8900a

Please sign in to comment.