MCPcopy Create free account
hub / github.com/Effect-TS/effect / viewer

Function viewer

packages/ui/devtools/src/node/DevToolsServer.ts:65–84  ·  view source on GitHub ↗
(size: number, fields: ReadonlyArray<string> | undefined)

Source from the content-addressed store, hash-verified

63const viewerFile = new URL("../../dist/viewer.html", import.meta.url)
64
65const viewer = (size: number, fields: ReadonlyArray<string> | undefined) =>
66 HttpRouter.add(
67 "GET",
68 "/",
69 Effect.map(
70 Effect.promise(() => readFile(viewerFile, "utf8").catch(() => undefined)),
71 (html) =>
72 html === undefined
73 ? HttpServerResponse.text(
74 "The DevTools page isn't built. Run `pnpm build-viewer` in @effect/ui-devtools.",
75 { status: 404 }
76 )
77 : HttpServerResponse.html(
78 html.replace(
79 "<head>",
80 () => "<head>" + Control.metaTag({ size, fields })
81 )
82 )
83 )
84 )
85
86/**
87 * The port the server listens on unless told otherwise. It's fixed, so a

Callers 1

layerFunction · 0.85

Calls 5

addMethod · 0.65
textMethod · 0.65
readFileFunction · 0.50
mapMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected