diff --git a/packages/platform/src/HttpApiBuilder.ts b/packages/platform/src/HttpApiBuilder.ts index 190c0bf8f6..1ead6c5cad 100644 --- a/packages/platform/src/HttpApiBuilder.ts +++ b/packages/platform/src/HttpApiBuilder.ts @@ -112,12 +112,12 @@ export const httpApp: Effect.Effect< * @since 1.0.0 * @category constructors * @example - * import type { HttpApi } from "@effect/platform" + * import { HttpApi } from "@effect/platform" * import { Etag, HttpApiBuilder, HttpMiddleware, HttpPlatform } from "@effect/platform" * import { NodeContext } from "@effect/platform-node" * import { Layer, ManagedRuntime } from "effect" * - * declare const ApiLive: Layer.Layer + * const ApiLive = HttpApiBuilder.api(HttpApi.empty) * * const runtime = ManagedRuntime.make( * Layer.mergeAll( diff --git a/packages/platform/src/internal/httpServerResponse.ts b/packages/platform/src/internal/httpServerResponse.ts index ef1ceff541..6648e66555 100644 --- a/packages/platform/src/internal/httpServerResponse.ts +++ b/packages/platform/src/internal/httpServerResponse.ts @@ -1,5 +1,6 @@ import type { ParseOptions } from "@effect/schema/AST" import type * as Schema from "@effect/schema/Schema" +import * as Context from "effect/Context" import * as Effect from "effect/Effect" import * as Effectable from "effect/Effectable" import { dual } from "effect/Function" @@ -11,7 +12,7 @@ import type * as PlatformError from "../Error.js" import type * as FileSystem from "../FileSystem.js" import * as Headers from "../Headers.js" import type * as Body from "../HttpBody.js" -import * as Platform from "../HttpPlatform.js" +import type * as Platform from "../HttpPlatform.js" import type * as Respondable from "../HttpServerRespondable.js" import type * as ServerResponse from "../HttpServerResponse.js" import * as Template from "../Template.js" @@ -214,13 +215,15 @@ export const schemaJson = ( )) } +const httpPlatform = Context.GenericTag("@effect/platform/HttpPlatform") + /** @internal */ export const file = ( path: string, options?: (ServerResponse.Options & FileSystem.StreamOptions) | undefined ): Effect.Effect => Effect.flatMap( - Platform.HttpPlatform, + httpPlatform, (platform) => platform.fileResponse(path, options) ) @@ -230,7 +233,7 @@ export const fileWeb = ( options?: (ServerResponse.Options.WithContent & FileSystem.StreamOptions) | undefined ): Effect.Effect => Effect.flatMap( - Platform.HttpPlatform, + httpPlatform, (platform) => platform.fileWebResponse(file, options) )