Skip to content

feat(server): add Effect-first host routes and async factory - #72

Merged
aryasaatvik merged 3 commits into
mainfrom
feat/domainkit-server-dx
Aug 31, 2026
Merged

feat(server): add Effect-first host routes and async factory#72
aryasaatvik merged 3 commits into
mainfrom
feat/domainkit-server-dx

Conversation

@aryasaatvik

@aryasaatvik aryasaatvik commented Aug 31, 2026

Copy link
Copy Markdown
Member

Summary

Mount one secure provider-connection handler in either an Effect-native or conventional async host. Identity, tenancy, continuations, provider configuration, durable persistence, and policy remain host-owned.

Usage

import { createDomainKit } from "domainkit/server";

const domainKit = await createDomainKit({
  baseURL: "https://app.example.com",
  identity,
  connectionPolicy,
  providers: [cloudflare],
  pendingAuthorizations,
  persistence,
});

app.all("/api/domainkit/*", (context) => domainKit.fetch(context.req.raw));

Effect applications retain explicit composition through Server.make, Server.layer, and Server.toWebHandler.

Flow

authenticated POST /connection/start
  -> host identity + provider flow
  -> host-owned one-time continuation
  -> provider authorization URL
  -> GET /callback/:providerId
  -> consume continuation + persist connection
  -> validated same-origin redirect

Both entry styles run the same Effect route program. The async factory requires host Promise persistence; it does not choose a database, run migrations, dispose the host client, or add async CapsuleDB support.

Validation

  • bun run lint
  • bun run format:check
  • bun run --cwd packages/domainkit release:check — 156 package tests and 7 packed-artifact tests, including Node, Bun, and workerd consumers
  • docs reference check, offline audit, and production build
  • git diff --check

The isolated Blume typecheck retains the pre-existing Astro/React/Bun typing baseline (70 errors on this branch; 75 on current main).

Follow-up scope

@domainkit/capsuledb remains an optional Effect-native persistence package in the existing follow-up PR. A later Samva PR will adopt the released API.

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Tegami

This repository uses Tegami to manage releases. When your changes affect published packages, add a changelog file under .tegami/ before merging.

Create a changelog → · Changelog format

No changelogs yet

This PR has no pending changelog files. If your changes require a release, add a changelog before merging.

Run bun run tegami locally to create a changelog interactively.

Managed by Tegami.

@aryasaatvik
aryasaatvik marked this pull request as ready for review August 31, 2026 12:23
@greptile-apps

greptile-apps Bot commented Aug 31, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds the domainkit/server entry point with shared Effect-native and Promise-host adapters for provider connection start and callback completion.

  • Adds host-provided identity, reuse policy, provider, continuation, persistence, and cryptography dependencies.
  • Exposes configurable Web routes with validated callbacks, one-time continuation consumption, and same-origin redirects.
  • Publishes the new entry point and expands its documentation, artifact tests, route tests, and lint boundaries.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/domainkit/src/server/index.ts Implements host service contracts, route handling, error-status mapping, root-path normalization, async adapters, and managed Web-handler lifecycle; the previously reported defects are corrected.
packages/domainkit/tests/server/routes.test.ts Covers authentication, tenant reuse denial, root mounting, continuation replay, callback validation, redirects, and unavailable pending-state storage.
packages/domainkit/src/server.ts Defines the public server entry point through a named async factory and Effect-oriented namespace.
packages/domainkit/package.json Publishes the new domainkit/server runtime and declaration artifacts.
apps/docs/content/reference/server.mdx Documents async and Effect-native composition, mounting, host responsibilities, routes, lifecycle disposal, and failure behavior.

Sequence Diagram

sequenceDiagram
  participant Client
  participant Handler as DomainKit Server
  participant Host as Host Services
  participant Provider
  Client->>Handler: POST /connection/start
  Handler->>Host: Authenticate and authorize reuse
  Handler->>Provider: Create interactive flow
  Handler->>Host: Persist one-time continuation
  Handler-->>Client: Authorization URL
  Client->>Provider: Complete provider consent
  Provider->>Handler: GET /callback/:providerId
  Handler->>Host: Load and consume continuation
  Handler->>Provider: Exchange callback payload
  Handler->>Host: Persist managed connection
  Handler-->>Client: 303 same-origin redirect
Loading

Reviews (5): Last reviewed commit: "feat(server): add async host factory" | Re-trigger Greptile

Comment thread packages/domainkit/src/server/index.ts Outdated
Comment thread packages/domainkit/src/server/index.ts
Comment thread packages/domainkit/src/server/index.ts
@aryasaatvik
aryasaatvik force-pushed the feat/domainkit-server-dx branch from 10f6cda to 92c7db0 Compare August 31, 2026 12:36
@aryasaatvik
aryasaatvik force-pushed the feat/domainkit-server-dx branch from e7fec92 to 3c8563d Compare August 31, 2026 16:57
Expose one host-mounted start and callback handler while keeping identity, provider configuration, continuations, durable authorization storage, and policy in host-provided Layers.
@aryasaatvik
aryasaatvik force-pushed the feat/domainkit-server-dx branch from 3c8563d to 8d40abc Compare August 31, 2026 19:58
@aryasaatvik aryasaatvik changed the title feat(server): add Effect-native host routes feat(server): add Effect-first host routes and async factory Aug 31, 2026
@aryasaatvik
aryasaatvik merged commit 52f3dd1 into main Aug 31, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant