Invoking API Endpoints Without Creating a New Server in `@effect/platform`

Heyo! Using the @effect/platform package, specifically for creating an api, is there a way to invoke the api endpoint without necessarily creating a new server?

For context, I'll be using remix route which will forward all the requests to my defined effect server.

The docs use the following example to layout how you serve the api.
import { HttpMiddleware, HttpServer } from "@effect/platform"
import { NodeHttpServer, NodeRuntime } from "@effect/platform-node"
import { createServer } from "node:http"

// use the `HttpApiBuilder.serve` function to register our API with the HTTP
// server
const HttpLive = HttpApiBuilder.serve(HttpMiddleware.logger).pipe(
  // Add CORS middleware
  Layer.provide(HttpApiBuilder.middlewareCors()),
  // Provide the API implementation
  Layer.provide(MyApiLive),
  // Log the address the server is listening on
  HttpServer.withLogAddress,
  // Provide the HTTP server implementation
  Layer.provide(NodeHttpServer.layer(createServer, { port: 3000 }))
)

// run the server
Layer.launch(HttpLive).pipe(NodeRuntime.runMain)


But is there a way to more or less provide the request to the api myself similar to what you're able to do with hono?
function handleRequest(args: LoaderFunctionArgs | ActionFunctionArgs) {
  const app = new Hono().basePath("/api").use(authenticateProxy);
  return app.fetch(args.request);
}

export const loader = async (args: LoaderFunctionArgs) => {
  return handleRequest(args);
};

export const action = async (args: ActionFunctionArgs) => {
  return handleRequest(args);
};


Thanks ahead of time 😄 !
Was this page helpful?