MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / serveTokenEndpoint

Function serveTokenEndpoint

packages/core/sdk/src/oauth-helpers.test.ts:40–65  ·  view source on GitHub ↗
(handler: TokenHandler)

Source from the content-addressed store, hash-verified

38 HttpServerResponse.jsonUnsafe(body, { status });
39
40const serveTokenEndpoint = (handler: TokenHandler) =>
41 Effect.gen(function* () {
42 const calls = yield* Ref.make<readonly TokenCall[]>([]);
43 const server = yield* serveTestHttpApp((request) =>
44 Effect.gen(function* () {
45 const bodyText = yield* request.text;
46 const call = {
47 method: request.method,
48 url: request.url ?? "/",
49 headers: request.headers,
50 body: new URLSearchParams(bodyText),
51 };
52 yield* Ref.update(calls, (all) => [...all, call]);
53 return handler(call);
54 }).pipe(
55 Effect.catch(() =>
56 Effect.succeed(HttpServerResponse.text("token fixture failed", { status: 500 })),
57 ),
58 ),
59 );
60
61 return {
62 tokenUrl: server.url("/token"),
63 calls: Ref.get(calls),
64 } as const;
65 });
66
67const withTokenEndpoint = <A, E>(
68 handler: TokenHandler,

Callers 1

withTokenEndpointFunction · 0.85

Calls 5

serveTestHttpAppFunction · 0.90
updateMethod · 0.65
textMethod · 0.65
getMethod · 0.65
handlerFunction · 0.50

Tested by

no test coverage detected