const HttpLive = HttpApiBuilder.serve(HttpMiddleware.logger).pipe(
// Add CORS middleware
Layer.provide(HttpApiBuilder.middlewareCors()),
// Provide the API implementation
Layer.provide(apiLive),
// Log the address the server is listening on
HttpServer.withLogAddress,
// Provide the HTTP server implementation
Layer.provide(NodeHttpServer.layer(createServer, { port: 3000 }))
)
HttpApiBuilder.toWebHandler(apiLive.pipe(
Layer.provide(NodeHttpPlatform.layer),
))
/*
^^ Gives errors:
Argument of type 'Layer<Api, never, never>' is not assignable to parameter of type 'Layer<Api | DefaultServices, never, never>'.
Type 'Api | DefaultServices' is not assignable to type 'Api'.
Type 'HttpPlatform' is missing the following properties from type 'TagClassShape<"@effect/platform/HttpApi/Api", { readonly api: HttpApi<AnyWithProps, never, never>; readonly context: Context<never>; }>': Id, Type, [TagTypeId]ts(2345)
*/
const HttpLive = HttpApiBuilder.serve(HttpMiddleware.logger).pipe(
// Add CORS middleware
Layer.provide(HttpApiBuilder.middlewareCors()),
// Provide the API implementation
Layer.provide(apiLive),
// Log the address the server is listening on
HttpServer.withLogAddress,
// Provide the HTTP server implementation
Layer.provide(NodeHttpServer.layer(createServer, { port: 3000 }))
)
HttpApiBuilder.toWebHandler(apiLive.pipe(
Layer.provide(NodeHttpPlatform.layer),
))
/*
^^ Gives errors:
Argument of type 'Layer<Api, never, never>' is not assignable to parameter of type 'Layer<Api | DefaultServices, never, never>'.
Type 'Api | DefaultServices' is not assignable to type 'Api'.
Type 'HttpPlatform' is missing the following properties from type 'TagClassShape<"@effect/platform/HttpApi/Api", { readonly api: HttpApi<AnyWithProps, never, never>; readonly context: Context<never>; }>': Id, Type, [TagTypeId]ts(2345)
*/