@effect/platform 0.35.0 → 0.37.0

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.
@@ -1,11 +1,11 @@
1
1
  import * as Context from "effect/Context"
2
2
  import * as Effect from "effect/Effect"
3
3
  import { dual } from "effect/Function"
4
+ import * as Layer from "effect/Layer"
4
5
  import type * as Scope from "effect/Scope"
5
6
  import type * as App from "../../Http/App.js"
6
7
  import type * as Middleware from "../../Http/Middleware.js"
7
8
  import type * as Server from "../../Http/Server.js"
8
- import type * as Error from "../../Http/ServerError.js"
9
9
  import type * as ServerRequest from "../../Http/ServerRequest.js"
10
10
 
11
11
  /** @internal */
@@ -27,40 +27,89 @@ export const make = (
27
27
  readonly serve: (
28
28
  httpApp: App.Default<never, unknown>,
29
29
  middleware?: Middleware.Middleware
30
- ) => Effect.Effect<Scope.Scope, Error.ServeError, never>
30
+ ) => Effect.Effect<Scope.Scope, never, void>
31
31
  readonly address: Server.Address
32
32
  }
33
33
  ): Server.Server => Object.assign(Object.create(serverProto), options)
34
34
 
35
35
  /** @internal */
36
36
  export const serve = dual<
37
+ {
38
+ (): <R, E>(
39
+ httpApp: App.Default<R, E>
40
+ ) => Layer.Layer<
41
+ Server.Server | Exclude<R, ServerRequest.ServerRequest>,
42
+ never,
43
+ never
44
+ >
45
+ <R, E, App extends App.Default<any, any>>(middleware: Middleware.Middleware.Applied<R, E, App>): (
46
+ httpApp: App.Default<R, E>
47
+ ) => Layer.Layer<
48
+ Server.Server | Exclude<Effect.Effect.Context<App>, ServerRequest.ServerRequest>,
49
+ never,
50
+ never
51
+ >
52
+ },
53
+ {
54
+ <R, E>(
55
+ httpApp: App.Default<R, E>
56
+ ): Layer.Layer<Server.Server | Exclude<R, ServerRequest.ServerRequest>, never, never>
57
+ <R, E, App extends App.Default<any, any>>(
58
+ httpApp: App.Default<R, E>,
59
+ middleware: Middleware.Middleware.Applied<R, E, App>
60
+ ): Layer.Layer<
61
+ Server.Server | Exclude<Effect.Effect.Context<App>, ServerRequest.ServerRequest>,
62
+ never,
63
+ never
64
+ >
65
+ }
66
+ >(
67
+ (args) => Effect.isEffect(args[0]),
68
+ <R, E, App extends App.Default<any, any>>(
69
+ httpApp: App.Default<R, E>,
70
+ middleware?: Middleware.Middleware.Applied<R, E, App>
71
+ ): Layer.Layer<
72
+ Server.Server | Exclude<Effect.Effect.Context<App>, ServerRequest.ServerRequest>,
73
+ never,
74
+ never
75
+ > =>
76
+ Layer.scopedDiscard(
77
+ Effect.flatMap(
78
+ serverTag,
79
+ (server) => server.serve(httpApp, middleware!)
80
+ )
81
+ ) as any
82
+ )
83
+
84
+ /** @internal */
85
+ export const serveEffect = dual<
37
86
  {
38
87
  (): <R, E>(
39
88
  httpApp: App.Default<R, E>
40
89
  ) => Effect.Effect<
41
90
  Server.Server | Scope.Scope | Exclude<R, ServerRequest.ServerRequest>,
42
- Error.ServeError,
43
- never
91
+ never,
92
+ void
44
93
  >
45
94
  <R, E, App extends App.Default<any, any>>(middleware: Middleware.Middleware.Applied<R, E, App>): (
46
95
  httpApp: App.Default<R, E>
47
96
  ) => Effect.Effect<
48
97
  Server.Server | Scope.Scope | Exclude<Effect.Effect.Context<App>, ServerRequest.ServerRequest>,
49
- Error.ServeError,
50
- never
98
+ never,
99
+ void
51
100
  >
52
101
  },
53
102
  {
54
103
  <R, E>(
55
104
  httpApp: App.Default<R, E>
56
- ): Effect.Effect<Server.Server | Scope.Scope | Exclude<R, ServerRequest.ServerRequest>, Error.ServeError, never>
105
+ ): Effect.Effect<Server.Server | Scope.Scope | Exclude<R, ServerRequest.ServerRequest>, never, void>
57
106
  <R, E, App extends App.Default<any, any>>(
58
107
  httpApp: App.Default<R, E>,
59
108
  middleware: Middleware.Middleware.Applied<R, E, App>
60
109
  ): Effect.Effect<
61
110
  Server.Server | Exclude<Effect.Effect.Context<App>, ServerRequest.ServerRequest> | Scope.Scope,
62
- Error.ServeError,
63
- never
111
+ never,
112
+ void
64
113
  >
65
114
  }
66
115
  >(
@@ -70,8 +119,8 @@ export const serve = dual<
70
119
  middleware: Middleware.Middleware.Applied<R, E, App>
71
120
  ): Effect.Effect<
72
121
  Server.Server | Exclude<Effect.Effect.Context<App>, ServerRequest.ServerRequest> | Scope.Scope,
73
- Error.ServeError,
74
- never
122
+ never,
123
+ void
75
124
  > =>
76
125
  Effect.flatMap(
77
126
  serverTag,