Skip to content

feat(server): serve on HttpApi and HttpRouter; delete config and db #77

Closed

Description

@allisonmahmood

Problem

With auth and patches ported, Fastify is only a shell around seams. This PR replaces it with Effect's HTTP server, moves serving into its own package, deletes the last pre-port packages and turns the Effect lint rules on.

Do

  • packages/serving: the serving guarantees (x-robots-tag, referrer-policy, CSP, cache-control, nosniff) as one raw HttpRouter.middleware(…, { global: true }); page routes /, /d/:patchId, /d/:patchId/v/:n, /healthz as HttpRouter routes reading through patches (render.ts, serving-headers.ts, public-url.ts move here); the trusted-proxy CIDR Schema feeding HttpMiddleware.xForwardedHeaders; the pre-routing target classification (400/404/414) kept as observable contract inside the raw middleware. Imports limits only if ticket 1 found a page rate limit survives.
  • apps/server: HttpApiBuilder.layer(PatchyApi) with the auth and patches group layers, the API-group middleware doing auth before body (no double rate-limit debit), Layer.mergeAll with the page router, NodeHttpServer.layer; per-capability Config composed here (Redacted secrets, fail on first missing key); the sweep forked in the server scope with Effect.repeat(job, Schedule.spaced("1 hour")); analytics finalizer on shutdown. Fastify and its plugins removed. Shape: packages/effect-slice/src/server.ts.
  • Delete packages/config (with env-registry.test.ts) and packages/db; the last runPromise seams go.
  • Tests: NodeHttpServer.layerTest for the headers and status contract as a socket sees them (app.test.ts becomes packages/serving tests + a thin apps/server boot test); HttpApiTest for the API through the real middleware; TestClock reaching the server fiber for the visit top-up.
  • Lint: the two t3code Effect ESLint rules written locally (namespace imports for service modules; no manual runtimes in tests; no schema compile in hot paths); promote every language-service warning rule to error repo-wide.
  • ADR Postgres only in docs/adr/ (JSON driver deleted, embedded-postgres for dev and tests). Move serving-guarantee terms to packages/serving/CONTEXT.md; apps/server/CONTEXT.md shrinks to wiring.
  • docs/DEVELOPMENT.md updated; the dev runner spawns the new server.

Done when

pnpm dev serves pages and the API from Effect with the same headers and status codes; the packed-CLI e2e passes; packages/config, packages/db, fastify are gone from the lockfile; pnpm lint fails on each new rule.

Decisions implemented

Spec §1, §3, §6, §7, §8, §10; vertical slice; #38 (Effect half).


Filed from the Effect v4 port spec (#68) by the map task Write the port spec and file the build tickets.

Activity

  1. added
    ready-for-agent
    area:server
    area:ci
    on Aug 28, 2026
  2. added 2 commits that reference this issue on Aug 29, 2026
    d55b46a
    7f06c23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:ciarea:serverready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions