// https://github.com/Effect-TS/effect/tree/main/packages/platform#registering-a-httpapiimport { HttpApi, HttpApiBuilder, HttpApiEndpoint, HttpApiGroup, HttpApiScalar, HttpLayerRouter} from "@effect/platform"import { NodeHttpServer, NodeRuntime } from "@effect/platform-node"import { Effect, Layer } from "effect"import { createServer } from "http"// First, we define our HttpApiclass MyApi extends HttpApi.make("api").add( HttpApiGroup.make("users") .add(HttpApiEndpoint.get("me", "/me")) .prefix("/users")) {}// Implement the handlers for the APIconst UsersApiLayer = HttpApiBuilder.group(MyApi, "users", (handers) => handers.handle("me", () => Effect.void))// Use `HttpLayerRouter.addHttpApi` to register the API with the routerconst HttpApiRoutes = HttpLayerRouter.addHttpApi(MyApi, { openapiPath: "/docs/openapi.json"}).pipe( // Provide the api handlers layer Layer.provide(UsersApiLayer))// Create a /docs route for the API documentationconst DocsRoute = HttpApiScalar.layerHttpLayerRouter({ api: MyApi, path: "/docs"})// Finally, we merge all routes and serve them using the Node HTTP serverconst AllRoutes = Layer.mergeAll(HttpApiRoutes, DocsRoute).pipe( Layer.provide(HttpLayerRouter.cors()))HttpLayerRouter.serve(AllRoutes).pipe( Layer.provide(NodeHttpServer.layer(createServer, { port: 3000 })), Layer.launch, NodeRuntime.runMain)