dev-browser.ts
This file
Path
apps/web/test/dev-browser.ts
66 lines · 2.1 KiB · TypeScript
Last changed by
Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248
History of this fileTake it
Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248
lines 1–2why, one step back1// Each `client-*.test.ts` file reads the one world its module's `backend` seeds, in order;2// within a file, only the last test changes it.Fold every page's project events once, keep Markdown off the first load, and cache what never changesoscabrielbefore adoption38e5215
lines 3–17why, one step back3import { ProjectName } from "@repo/protocol/ids";4import { env } from "cloudflare:workers";5import { Effect, Layer } from "effect";6import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http";7import { Atom, AtomRegistry, Reactivity } from "effect/reactivity";8import type { AsyncResult } from "effect/reactivity";9import { RpcClient, RpcSerialization } from "effect/rpc";1011import { backend } from "#backend";1213import { SESSION_COOKIE } from "../src/server/session.ts";14import { ContractsClient, webContracts } from "../src/surfaces.ts";1516export const WEB_URL = "http://localhost:3000";17Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 18why, one step back18export const datekit = ProjectName.make("oscabriel/datekit");Fold every page's project events once, keep Markdown off the first load, and cache what never changesoscabrielbefore adoption38e5215
lines 19–64why, one step back1920export const DECIDER = "dev-ines-v";2122const browser = (token?: string) =>23 Layer.effect(24 ContractsClient,25 RpcClient.make(webContracts, { flatten: true })26 ).pipe(27 Layer.provide(28 RpcClient.layerProtocolHttp({29 transformClient: HttpClient.mapRequest((request) =>30 token === undefined31 ? request32 : HttpClientRequest.setHeader(33 request,34 "cookie",35 `${SESSION_COOKIE}=${token}`36 )37 ),38 url: `${WEB_URL}/rpc`,39 })40 ),41 Layer.provide([FetchHttpClient.layer, RpcSerialization.layerJson]),42 Layer.provide(43 Layer.succeed(FetchHttpClient.Fetch, (input, init) =>44 backend(new Request(input, init), env)45 )46 ),47 Layer.provideMerge(Reactivity.layer)48 );4950export const registryAs = (token?: string) =>51 AtomRegistry.make({52 initialValues: [53 Atom.initialValue(ContractsClient.runtime.layer, browser(token)),54 ],55 });5657export const settled = <A, E>(58 registry: AtomRegistry.AtomRegistry,59 atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>60) =>61 Effect.exit(62 AtomRegistry.getResult(registry, atom, { suspendOnWaiting: true })63 );64Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248
line 65why, one step back65// Cold seeding while turbo runs every package's tests at once comes near vitest's 5 s default.Fold every page's project events once, keep Markdown off the first load, and cache what never changesoscabrielbefore adoption38e5215
line 66why, one step back66export const seededWorld = { timeout: 30_000 };