Effect CommunityEC
Effect Community11mo ago
53 replies
Stephen Bluck

Converting ViteDevServer to NodeHttpServer with Effect and Vite

I am trying to wrap a Vite dev server with Effect. I am not sure what types I need in order to end up with a NodeHttpServer. Basically how can I go from a ViteDevServer -> NodeHttpServer .

I have checked out NodeHttpServer.make but can't seem to workout how to wire it up. Here is what I have so far:
import * as Vite from "vite";

const devServer: Effect.Effect<Vite.ViteDevServer> = Effect.promise(() =>
  Vite.createServer()
);

// Obivoulsy have a type error at the moment
const ServerDev = app.pipe(
  Layer.provide(NodeHttpServer.make(Vite.createServer, { port: 4000 }))
);

Layer.launch(ServerDev).pipe(NodeRuntime.runMain);
Was this page helpful?