Skip to content

Commit f6987c0

Browse files
authored
add additional predicate typings for HttpMiddleware.cors allowOrigins (#5588)
Co-authored-by: Wayne Maurer <[email protected]>
1 parent f4c4702 commit f6987c0

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

.changeset/tidy-seals-grow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@effect/platform": patch
3+
---
4+
5+
add additional predicate typings for HttpMiddleware.cors allowOrigins

packages/platform/src/HttpApiBuilder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import * as Layer from "effect/Layer"
1313
import * as Option from "effect/Option"
1414
import * as ParseResult from "effect/ParseResult"
1515
import { type Pipeable, pipeArguments } from "effect/Pipeable"
16+
import type * as Predicate from "effect/Predicate"
1617
import type { ReadonlyRecord } from "effect/Record"
1718
import * as Redacted from "effect/Redacted"
1819
import * as Schema from "effect/Schema"
@@ -964,7 +965,7 @@ export const middleware: {
964965
*/
965966
export const middlewareCors = (
966967
options?: {
967-
readonly allowedOrigins?: ReadonlyArray<string> | undefined
968+
readonly allowedOrigins?: ReadonlyArray<string> | Predicate.Predicate<string> | undefined
968969
readonly allowedMethods?: ReadonlyArray<string> | undefined
969970
readonly allowedHeaders?: ReadonlyArray<string> | undefined
970971
readonly exposedHeaders?: ReadonlyArray<string> | undefined

packages/platform/src/HttpLayerRouter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import * as FiberRef from "effect/FiberRef"
1010
import { compose, constant, dual, identity } from "effect/Function"
1111
import * as Layer from "effect/Layer"
1212
import * as Option from "effect/Option"
13+
import type * as Predicate from "effect/Predicate"
1314
import * as Scope from "effect/Scope"
1415
import * as Tracer from "effect/Tracer"
1516
import type * as Types from "effect/Types"
@@ -903,7 +904,7 @@ export declare namespace middleware {
903904
*/
904905
export const cors = (
905906
options?: {
906-
readonly allowedOrigins?: ReadonlyArray<string> | undefined
907+
readonly allowedOrigins?: ReadonlyArray<string> | Predicate.Predicate<string> | undefined
907908
readonly allowedMethods?: ReadonlyArray<string> | undefined
908909
readonly allowedHeaders?: ReadonlyArray<string> | undefined
909910
readonly exposedHeaders?: ReadonlyArray<string> | undefined

packages/platform/src/HttpMiddleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export const searchParamsParser: <E, R>(
122122
*/
123123
export const cors: (
124124
options?: {
125-
readonly allowedOrigins?: ReadonlyArray<string> | undefined
125+
readonly allowedOrigins?: ReadonlyArray<string> | Predicate.Predicate<string> | undefined
126126
readonly allowedMethods?: ReadonlyArray<string> | undefined
127127
readonly allowedHeaders?: ReadonlyArray<string> | undefined
128128
readonly exposedHeaders?: ReadonlyArray<string> | undefined

0 commit comments

Comments
 (0)