feat(rpc): add the caller-side example and close remaining coverage gaps

Adds examples/auth-showcase/app/services/greeter-client.ts so the showcase
demonstrates both halves - the review noted the example was callee-only, so a
developer had no working reference for making a call.

Raises integration coverage to the planned 3 tests and adds the missing
rpc-endpoint cases. Also wires the prod build path for services.

304 tests pass across rpc/router/dev-server/cli; typecheck, lint, format and
check:public-api all clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-05 20:21:41 +05:30
co-authored by Claude Opus 5
parent ce68803471
commit 6aaf21aa06
8 changed files with 105 additions and 7 deletions
@@ -2,6 +2,7 @@ import { describe, expect, test } from "bun:test";
import { defineService, implement, procedure } from "@wrnexus/rpc";
import { v } from "@wrnexus/validation";
import { handleRpcRequest, isInternalCaller, isRpcPath } from "../src/rpc-dispatch.ts";
import { createProductionHandlers, type ProdManifest } from "../src/prod.ts";
const demo = defineService({
name: "demo",
@@ -73,4 +74,20 @@ describe("RPC endpoint", () => {
expect(await res!.json()).toMatchObject({ ok: false, code: "RPC_UNKNOWN" });
});
});
test("production manifests load and dispatch service implementations", async () => {
const manifest: ProdManifest = {
pages: [],
api: [],
realtime: [],
middleware: [],
components: [],
layouts: [],
services: [{ name: "demo", mod: { default: services.get("demo") } }],
};
const handlers = createProductionHandlers(manifest, {});
const req = request("/__wrnexus/rpc/demo/add", { "x-wrnexus-internal": "1" });
const response = await handlers.fetch(req, {} as never);
expect(await response!.json()).toEqual({ ok: true, value: { a: 2 } });
});
});