@powerhousedao/reactor-api 6.2.3-dev.1 → 6.2.3-dev.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +7 -2
  2. package/dist/{adapter-gateway-apollo-DdamNLPT.mjs → adapter-gateway-apollo-D-EdZ4e-.mjs} +23 -24
  3. package/dist/adapter-gateway-apollo-D-EdZ4e-.mjs.map +1 -0
  4. package/dist/{adapter-gateway-mercurius-CLmTtNJC.mjs → adapter-gateway-mercurius-CdxLge5p.mjs} +4 -11
  5. package/dist/adapter-gateway-mercurius-CdxLge5p.mjs.map +1 -0
  6. package/dist/{adapter-http-express-54gdI9bu.mjs → adapter-http-express-78KD77cI.mjs} +11 -11
  7. package/dist/adapter-http-express-78KD77cI.mjs.map +1 -0
  8. package/dist/{adapter-http-fastify-DmccBVOe.mjs → adapter-http-fastify-Dk7aT_xw.mjs} +14 -13
  9. package/dist/adapter-http-fastify-Dk7aT_xw.mjs.map +1 -0
  10. package/dist/base-document-models-caJpqTLw.mjs +2083 -0
  11. package/dist/base-document-models-caJpqTLw.mjs.map +1 -0
  12. package/dist/create-schema-BCArFBv9.d.mts +167 -0
  13. package/dist/create-schema-BCArFBv9.d.mts.map +1 -0
  14. package/dist/error-info-Cr6oQACe.mjs +601 -0
  15. package/dist/error-info-Cr6oQACe.mjs.map +1 -0
  16. package/dist/index.d.mts +3410 -1028
  17. package/dist/index.d.mts.map +1 -1
  18. package/dist/index.mjs +7549 -2724
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/package-subgraph-check-BxKx9kcQ.mjs +138 -0
  21. package/dist/package-subgraph-check-BxKx9kcQ.mjs.map +1 -0
  22. package/dist/pglite-like-CKQEL_Q0.d.mts +27 -0
  23. package/dist/pglite-like-CKQEL_Q0.d.mts.map +1 -0
  24. package/dist/pglite-node-CcX2YT-l.mjs +744 -0
  25. package/dist/pglite-node-CcX2YT-l.mjs.map +1 -0
  26. package/dist/rolldown-runtime-8H4AJuhK.mjs +16 -0
  27. package/dist/run-node-handler-CQjyjOuN.mjs +52 -0
  28. package/dist/run-node-handler-CQjyjOuN.mjs.map +1 -0
  29. package/dist/src/graphql/subgraph-types.d.mts +43 -0
  30. package/dist/src/graphql/subgraph-types.d.mts.map +1 -0
  31. package/dist/src/graphql/subgraph-types.mjs +14 -0
  32. package/dist/src/graphql/subgraph-types.mjs.map +1 -0
  33. package/dist/src/packages/https-hooks.d.mts +4 -4
  34. package/dist/src/packages/https-hooks.d.mts.map +1 -1
  35. package/dist/src/packages/https-hooks.mjs +2 -2
  36. package/dist/src/packages/https-hooks.mjs.map +1 -1
  37. package/dist/src/packages/vite-loader.d.mts +30 -9
  38. package/dist/src/packages/vite-loader.d.mts.map +1 -1
  39. package/dist/src/packages/vite-loader.mjs +208 -88
  40. package/dist/src/packages/vite-loader.mjs.map +1 -1
  41. package/dist/src/pglite/pglite-node.d.mts +434 -0
  42. package/dist/src/pglite/pglite-node.d.mts.map +1 -0
  43. package/dist/src/pglite/pglite-node.mjs +5 -0
  44. package/dist/src/pglite/worker/entry.d.mts +2 -0
  45. package/dist/src/pglite/worker/entry.mjs +298 -0
  46. package/dist/src/pglite/worker/entry.mjs.map +1 -0
  47. package/dist/subgraph-extraction-C_hFvSaS.mjs +1884 -0
  48. package/dist/subgraph-extraction-C_hFvSaS.mjs.map +1 -0
  49. package/dist/subgraph-schema-owner-BEjuk2Xv.mjs +10 -0
  50. package/dist/subgraph-schema-owner-BEjuk2Xv.mjs.map +1 -0
  51. package/dist/types-Bz_xjf8j.d.mts +105 -0
  52. package/dist/types-Bz_xjf8j.d.mts.map +1 -0
  53. package/package.json +42 -26
  54. package/dist/adapter-gateway-apollo-DdamNLPT.mjs.map +0 -1
  55. package/dist/adapter-gateway-mercurius-CLmTtNJC.mjs.map +0 -1
  56. package/dist/adapter-http-express-54gdI9bu.mjs.map +0 -1
  57. package/dist/adapter-http-fastify-DmccBVOe.mjs.map +0 -1
  58. package/dist/path-normalize-DWWFLiy6.mjs +0 -23
  59. package/dist/path-normalize-DWWFLiy6.mjs.map +0 -1
  60. package/dist/types-Bz2niABC.d.mts +0 -48
  61. package/dist/types-Bz2niABC.d.mts.map +0 -1
  62. package/dist/utils-XWVecaNn.mjs +0 -653
  63. package/dist/utils-XWVecaNn.mjs.map +0 -1
  64. package/dist/websocket-DncAB9XK.mjs +0 -18
  65. package/dist/websocket-DncAB9XK.mjs.map +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @powerhousedao/reactor-api
2
2
 
3
- A powerful API server implementation for the Powerhouse ecosystem that provides GraphQL capabilities, document processing, and package management.
3
+ An API server for Powerhouse: GraphQL, document processing and package management.
4
4
 
5
5
  ## Features
6
6
 
@@ -39,12 +39,17 @@ const api = await startAPI(reactor, {
39
39
 
40
40
  ### API Server
41
41
 
42
- The API server provides a robust Express-based implementation with GraphQL support, authentication middleware, and HTTPS capabilities.
42
+ An Express server with GraphQL, authentication middleware and HTTPS.
43
43
 
44
44
  ### Package Manager
45
45
 
46
46
  Manages document models, subgraphs, and processors through a flexible loading system that supports multiple package sources.
47
47
 
48
+ It also finds each package's pieces through its `./pieces` export, the built
49
+ `pieces/index.ts` list. It imports only that list, never piece code, reads each
50
+ piece's version from the package's `package.json`, and hands the entry paths to
51
+ the workflow runtime, which runs them in a forked worker.
52
+
48
53
  ### GraphQL Manager
49
54
 
50
55
  Handles GraphQL operations, subgraph management, and schema composition using Apollo Server.
@@ -1,13 +1,18 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="77c68ea0-45a9-5982-9dc4-6194ce0c3ef5")}catch(e){}}();
3
- import { t as useServer } from "./websocket-DncAB9XK.mjs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4b08cabd-f774-5807-9d1f-f0a6822a26ad")}catch(e){}}();
3
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
4
4
  import { buildSubgraphSchema } from "@apollo/subgraph";
5
- import { ApolloGateway, LocalCompose, RemoteGraphQLDataSource } from "@apollo/gateway";
6
5
  import { ApolloServer, HeaderMap } from "@apollo/server";
7
6
  import { ApolloServerPluginInlineTraceDisabled } from "@apollo/server/plugin/disabled";
8
- import { ApolloServerPluginDrainHttpServer } from "@apollo/server/plugin/drainHttpServer";
9
7
  import { ApolloServerPluginLandingPageLocalDefault } from "@apollo/server/plugin/landingPage/default";
8
+ import { ApolloGateway, LocalCompose, RemoteGraphQLDataSource } from "@apollo/gateway";
9
+ import { ApolloServerPluginDrainHttpServer } from "@apollo/server/plugin/drainHttpServer";
10
10
  //#region src/graphql/gateway/adapter-gateway-apollo.ts
11
+ var adapter_gateway_apollo_exports = /* @__PURE__ */ __exportAll({
12
+ ApolloGatewayAdapter: () => ApolloGatewayAdapter,
13
+ createApolloFetchHandler: () => createApolloFetchHandler,
14
+ filterComposableSubgraphs: () => filterComposableSubgraphs
15
+ });
11
16
  /**
12
17
  * Drop subgraphs whose typeDefs cannot be built into a valid subgraph schema in
13
18
  * isolation — e.g. a duplicate type definition within a single subgraph (Sentry
@@ -66,14 +71,15 @@ var ApolloGatewayAdapter = class {
66
71
  async createSupergraphHandler(getSubgraphs, httpServer, contextFactory) {
67
72
  if (this.#supergraphServer) throw new Error("Supergraph server is already running");
68
73
  this.#getSubgraphs = getSubgraphs;
74
+ const gateway = new ApolloGateway({
75
+ supergraphSdl: async (options) => {
76
+ this.#gatewayOptions = options;
77
+ return await this.#buildSupergraphSdl();
78
+ },
79
+ buildService: (serviceConfig) => new AuthenticatedDataSource(serviceConfig)
80
+ });
69
81
  this.#supergraphServer = new ApolloServer({
70
- gateway: new ApolloGateway({
71
- supergraphSdl: async (options) => {
72
- this.#gatewayOptions = options;
73
- return await this.#buildSupergraphSdl();
74
- },
75
- buildService: (serviceConfig) => new AuthenticatedDataSource(serviceConfig)
76
- }),
82
+ gateway,
77
83
  logger: this.#logger,
78
84
  introspection: true,
79
85
  stopOnTerminationSignals: false,
@@ -93,19 +99,12 @@ var ApolloGatewayAdapter = class {
93
99
  }
94
100
  async #buildSupergraphSdl() {
95
101
  if (!this.#gatewayOptions || !this.#getSubgraphs) throw new Error("Gateway is not ready");
96
- return new LocalCompose({ localServiceList: filterComposableSubgraphs(this.#getSubgraphs().map((s) => ({
102
+ const composableServiceList = filterComposableSubgraphs(this.#getSubgraphs().map((s) => ({
97
103
  name: s.name,
98
104
  typeDefs: s.typeDefs,
99
105
  url: s.url
100
- })), this.#logger) }).initialize(this.#gatewayOptions);
101
- }
102
- attachWebSocket(wsServer, schema, contextFactory) {
103
- return useServer({
104
- schema,
105
- context: async (ctx) => {
106
- return contextFactory(ctx.connectionParams ?? {});
107
- }
108
- }, wsServer);
106
+ })), this.#logger);
107
+ return new LocalCompose({ localServiceList: composableServiceList }).initialize(this.#gatewayOptions);
109
108
  }
110
109
  async stop() {
111
110
  await Promise.all(this.#servers.map((s) => s.stop()));
@@ -156,7 +155,7 @@ function createApolloFetchHandler(server, contextFactory) {
156
155
  };
157
156
  }
158
157
  //#endregion
159
- export { ApolloGatewayAdapter };
158
+ export { createApolloFetchHandler as n, adapter_gateway_apollo_exports as t };
160
159
 
161
- //# sourceMappingURL=adapter-gateway-apollo-DdamNLPT.mjs.map
162
- //# debugId=77c68ea0-45a9-5982-9dc4-6194ce0c3ef5
160
+ //# sourceMappingURL=adapter-gateway-apollo-D-EdZ4e-.mjs.map
161
+ //# debugId=4b08cabd-f774-5807-9d1f-f0a6822a26ad
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-gateway-apollo-D-EdZ4e-.mjs","sources":["../src/graphql/gateway/adapter-gateway-apollo.ts"],"sourcesContent":["import type {\n GetDataSourceFunction,\n GraphQLDataSourceProcessOptions,\n ServiceDefinition,\n SubgraphHealthCheckFunction,\n SupergraphSdlUpdateFunction,\n} from \"@apollo/gateway\";\nimport {\n ApolloGateway,\n LocalCompose,\n RemoteGraphQLDataSource,\n} from \"@apollo/gateway\";\nimport { ApolloServer, HeaderMap } from \"@apollo/server\";\nimport { ApolloServerPluginInlineTraceDisabled } from \"@apollo/server/plugin/disabled\";\nimport { ApolloServerPluginDrainHttpServer } from \"@apollo/server/plugin/drainHttpServer\";\nimport { ApolloServerPluginLandingPageLocalDefault } from \"@apollo/server/plugin/landingPage/default\";\nimport { buildSubgraphSchema } from \"@apollo/subgraph\";\nimport type { ILogger } from \"document-model\";\nimport type { GraphQLSchema } from \"graphql\";\nimport type http from \"node:http\";\nimport type { Context } from \"../types.js\";\nimport type {\n FetchHandler,\n GatewayContextFactory,\n IGatewayAdapter,\n SubgraphDefinition,\n} from \"./types.js\";\n\n/**\n * Drop subgraphs whose typeDefs cannot be built into a valid subgraph schema in\n * isolation — e.g. a duplicate type definition within a single subgraph (Sentry\n * #917) — so one broken subgraph is excluded instead of failing the build for\n * everyone. Each excluded subgraph is logged; the rest are composed.\n *\n * Scope: this only catches per-subgraph build failures. Errors that surface only\n * when subgraphs are composed together (cross-subgraph type or `@key` conflicts)\n * are still thrown by `LocalCompose.initialize()` and are NOT handled here.\n */\nexport function filterComposableSubgraphs(\n serviceList: ServiceDefinition[],\n logger?: Pick<ILogger, \"error\">,\n): ServiceDefinition[] {\n return serviceList.filter((service) => {\n try {\n // Array form: @apollo/subgraph 2.15 dropped the bare-module overload.\n buildSubgraphSchema([{ typeDefs: service.typeDefs }]);\n return true;\n } catch (error) {\n logger?.error(\n `Excluding subgraph \"${service.name}\" from supergraph composition: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n return false;\n }\n });\n}\n\n// Forwards the incoming authorization header to federated subgraph requests.\nclass AuthenticatedDataSource extends RemoteGraphQLDataSource {\n constructor(\n config?: ConstructorParameters<typeof RemoteGraphQLDataSource>[0],\n ) {\n // Node's fetch retires a pooled connection before the subgraph server's advertised keep-alive\n // timeout; Apollo's default make-fetch-happen agent holds it until the server closes it under us.\n super({\n fetcher: fetch as RemoteGraphQLDataSource[\"fetcher\"],\n ...config,\n });\n }\n\n override willSendRequest(options: GraphQLDataSourceProcessOptions) {\n const { authorization } = options.context.headers as {\n authorization: string;\n };\n if (authorization && options?.request.http) {\n options.request.http.headers.set(\"authorization\", authorization);\n }\n }\n}\n\nexport class ApolloGatewayAdapter implements IGatewayAdapter<Context> {\n readonly #logger: ILogger;\n readonly #servers: ApolloServer<Context>[] = [];\n\n #supergraphServer: ApolloServer<Context> | null = null;\n #gatewayOptions: {\n update: SupergraphSdlUpdateFunction;\n healthCheck: SubgraphHealthCheckFunction;\n getDataSource: GetDataSourceFunction;\n } | null = null;\n #getSubgraphs: (() => SubgraphDefinition[]) | null = null;\n\n constructor(logger: ILogger) {\n this.#logger = logger;\n }\n\n async start(_httpServer: http.Server): Promise<void> {\n // Per-subgraph Apollo servers start lazily in createHandler.\n // Nothing to do here.\n }\n\n async createHandler(\n schema: GraphQLSchema,\n contextFactory: GatewayContextFactory<Context>,\n ): Promise<FetchHandler> {\n const server = new ApolloServer<Context>({\n schema,\n logger: this.#logger,\n introspection: true,\n // Each ApolloServer otherwise registers its own SIGINT/SIGTERM handler\n // that re-emits the signal via process.kill after server.stop() resolves.\n // With many subgraph servers that re-emit lands while the reactor's\n // graceful-shutdown chain is mid-flight, looking like a \"second SIGINT\"\n // to the reactor and aborting cleanup. The reactor drives our shutdown\n // end-to-end (see ReactorBuilder.attachSignalHandlers), so opt out.\n stopOnTerminationSignals: false,\n plugins: [\n ApolloServerPluginInlineTraceDisabled(),\n ApolloServerPluginLandingPageLocalDefault(),\n ],\n });\n await server.start();\n this.#servers.push(server);\n return createApolloFetchHandler(server, contextFactory);\n }\n\n async createSupergraphHandler(\n getSubgraphs: () => SubgraphDefinition[],\n httpServer: http.Server,\n contextFactory: GatewayContextFactory<Context>,\n ): Promise<FetchHandler> {\n if (this.#supergraphServer) {\n throw new Error(\"Supergraph server is already running\");\n }\n\n this.#getSubgraphs = getSubgraphs;\n\n const gateway = new ApolloGateway({\n supergraphSdl: async (options) => {\n this.#gatewayOptions = options;\n return await this.#buildSupergraphSdl();\n },\n buildService: (serviceConfig) =>\n new AuthenticatedDataSource(serviceConfig),\n });\n\n this.#supergraphServer = new ApolloServer<Context>({\n gateway,\n logger: this.#logger,\n introspection: true,\n stopOnTerminationSignals: false,\n plugins: [\n ApolloServerPluginDrainHttpServer({ httpServer }),\n ApolloServerPluginInlineTraceDisabled(),\n ApolloServerPluginLandingPageLocalDefault(),\n ],\n });\n\n await this.#supergraphServer.start();\n return createApolloFetchHandler(this.#supergraphServer, contextFactory);\n }\n\n async updateSupergraph(): Promise<void> {\n if (!this.#gatewayOptions || !this.#getSubgraphs) {\n // Not yet initialized - no-op.\n return;\n }\n const { supergraphSdl } = await this.#buildSupergraphSdl();\n this.#gatewayOptions.update(supergraphSdl);\n }\n\n async #buildSupergraphSdl() {\n if (!this.#gatewayOptions || !this.#getSubgraphs) {\n throw new Error(\"Gateway is not ready\");\n }\n const serviceList: ServiceDefinition[] = this.#getSubgraphs().map((s) => ({\n name: s.name,\n typeDefs: s.typeDefs,\n url: s.url,\n }));\n const composableServiceList = filterComposableSubgraphs(\n serviceList,\n this.#logger,\n );\n const localCompose = new LocalCompose({\n localServiceList: composableServiceList,\n });\n return localCompose.initialize(this.#gatewayOptions);\n }\n\n async stop(): Promise<void> {\n await Promise.all(this.#servers.map((s) => s.stop()));\n this.#servers.length = 0;\n\n if (this.#supergraphServer) {\n await this.#supergraphServer.stop();\n this.#supergraphServer = null;\n }\n this.#gatewayOptions = null;\n this.#getSubgraphs = null;\n }\n}\n\n/**\n * Wrap an existing ApolloServer as a Fetch API handler.\n * Does not manage server lifecycle; caller is responsible for start/stop.\n */\nexport function createApolloFetchHandler(\n server: ApolloServer<Context>,\n contextFactory: GatewayContextFactory<Context>,\n): FetchHandler {\n return async (request: Request): Promise<Response> => {\n const url = new URL(request.url);\n const headers = new HeaderMap();\n request.headers.forEach((value, key) => headers.set(key, value));\n\n let body: unknown = undefined;\n if (request.method !== \"GET\" && request.method !== \"HEAD\") {\n try {\n body = (await request.json()) as unknown;\n } catch {\n // body may be empty for some requests\n }\n }\n\n const result = await server.executeHTTPGraphQLRequest({\n httpGraphQLRequest: {\n method: request.method.toUpperCase(),\n headers,\n search: url.search,\n body,\n },\n context: () => contextFactory(request),\n });\n\n const responseHeaders = new Headers();\n for (const [key, value] of result.headers) {\n responseHeaders.set(key, value);\n }\n\n let responseBody: string;\n if (result.body.kind === \"complete\") {\n responseBody = result.body.string;\n } else {\n const chunks: string[] = [];\n for await (const chunk of result.body.asyncIterator) {\n chunks.push(chunk);\n }\n responseBody = chunks.join(\"\");\n }\n\n return new Response(responseBody, {\n status: result.status ?? 200,\n headers: responseHeaders,\n });\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,0BACd,aACA,QACqB;CACrB,OAAO,YAAY,QAAQ,YAAY;EACrC,IAAI;GAEF,oBAAoB,CAAC,EAAE,UAAU,QAAQ,SAAS,CAAC,CAAC;GACpD,OAAO;EACT,SAAS,OAAO;GACd,QAAQ,MACN,uBAAuB,QAAQ,KAAK,iCAClC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAEzD;GACA,OAAO;EACT;CACF,CAAC;AACH;AAGA,IAAM,0BAAN,cAAsC,wBAAwB;CAC5D,YACE,QACA;EAGA,MAAM;GACJ,SAAS;GACT,GAAG;EACL,CAAC;CACH;CAEA,gBAAyB,SAA0C;EACjE,MAAM,EAAE,kBAAkB,QAAQ,QAAQ;EAG1C,IAAI,iBAAiB,SAAS,QAAQ,MACpC,QAAQ,QAAQ,KAAK,QAAQ,IAAI,iBAAiB,aAAa;CAEnE;AACF;AAEA,IAA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,OAAO,KAAK,EAAE;EAC/B;EAEA,OAAO,IAAI,SAAS,cAAc;GAChC,QAAQ,OAAO,UAAU;GACzB,SAAS;EACX,CAAC;CACH;AACF","debug_id":"4b08cabd-f774-5807-9d1f-f0a6822a26ad"}
@@ -1,10 +1,9 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b5ea3d3a-7b76-5891-97bf-dc76e50f3387")}catch(e){}}();
3
- import { t as useServer } from "./websocket-DncAB9XK.mjs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5f791eb2-83b0-5fbd-a834-cc764eb2823a")}catch(e){}}();
3
+ import { AsyncLocalStorage } from "node:async_hooks";
4
4
  import mercuriusGateway from "@mercuriusjs/gateway";
5
5
  import Fastify from "fastify";
6
6
  import mercurius from "mercurius";
7
- import { AsyncLocalStorage } from "node:async_hooks";
8
7
  //#region src/graphql/gateway/adapter-gateway-mercurius.ts
9
8
  /**
10
9
  * Threads the original Fetch API Request through Mercurius's internal
@@ -47,12 +46,6 @@ var MercuriusGatewayAdapter = class {
47
46
  this.#supergraphApp = newApp;
48
47
  if (oldApp) await oldApp.close();
49
48
  }
50
- attachWebSocket(wsServer, schema, contextFactory) {
51
- return useServer({
52
- schema,
53
- context: async (ctx) => contextFactory(ctx.connectionParams ?? {})
54
- }, wsServer);
55
- }
56
49
  async stop() {
57
50
  await Promise.all(this.#subgraphApps.map((app) => app.close()));
58
51
  this.#subgraphApps.length = 0;
@@ -128,5 +121,5 @@ async function injectRequest(app, request) {
128
121
  //#endregion
129
122
  export { MercuriusGatewayAdapter };
130
123
 
131
- //# sourceMappingURL=adapter-gateway-mercurius-CLmTtNJC.mjs.map
132
- //# debugId=b5ea3d3a-7b76-5891-97bf-dc76e50f3387
124
+ //# sourceMappingURL=adapter-gateway-mercurius-CdxLge5p.mjs.map
125
+ //# debugId=5f791eb2-83b0-5fbd-a834-cc764eb2823a
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-gateway-mercurius-CdxLge5p.mjs","sources":["../src/graphql/gateway/adapter-gateway-mercurius.ts"],"sourcesContent":["import type { MercuriusGatewayOptions } from \"@mercuriusjs/gateway\";\nimport mercuriusGateway from \"@mercuriusjs/gateway\";\nimport Fastify from \"fastify\";\nimport type {\n FastifyInstance,\n FastifyPluginCallback,\n FastifyReply,\n FastifyRequest,\n} from \"fastify\";\nimport mercurius from \"mercurius\";\nimport type { MercuriusOptions } from \"mercurius\";\nimport type { ILogger } from \"document-model\";\nimport type { GraphQLSchema } from \"graphql\";\nimport type http from \"node:http\";\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport type { Context } from \"../types.js\";\nimport type {\n FetchHandler,\n GatewayContextFactory,\n IGatewayAdapter,\n SubgraphDefinition,\n} from \"./types.js\";\n\n/**\n * Threads the original Fetch API Request through Mercurius's internal\n * fastify.inject() call so that contextFactory (which uses the auth WeakMap\n * from auth-middleware.ts) receives the same Request object that auth\n * middleware populated before calling the handler.\n */\nconst requestAls = new AsyncLocalStorage<Request>();\n\n// @mercuriusjs/gateway exports a plain `(instance, opts) => void` rather than\n// a typed FastifyPluginCallback — cast once here.\n// The gateway plugin's accepted options are the intersection of the base\n// MercuriusOptions and MercuriusGatewayOptions (mirroring the unexported\n// MercuriusFederationOptions type in the package).\ntype GatewayPluginOptions = MercuriusOptions & MercuriusGatewayOptions;\nconst mercuriusGatewayPlugin =\n mercuriusGateway as unknown as FastifyPluginCallback<GatewayPluginOptions>;\n\nexport class MercuriusGatewayAdapter implements IGatewayAdapter<Context> {\n readonly #logger: ILogger;\n readonly #subgraphApps: FastifyInstance[] = [];\n\n #supergraphApp: FastifyInstance | null = null;\n #getSubgraphs: (() => SubgraphDefinition[]) | null = null;\n #supergraphContextFactory: GatewayContextFactory<Context> | null = null;\n\n constructor(logger: ILogger) {\n this.#logger = logger;\n }\n\n async start(_httpServer: http.Server): Promise<void> {\n // Mercurius instances are started lazily in createHandler /\n // createSupergraphHandler — nothing to do here.\n }\n\n async createHandler(\n schema: GraphQLSchema,\n contextFactory: GatewayContextFactory<Context>,\n ): Promise<FetchHandler> {\n const app = await buildMercuriusApp(schema, contextFactory, this.#logger);\n this.#subgraphApps.push(app);\n return buildFetchHandler(app);\n }\n\n async createSupergraphHandler(\n getSubgraphs: () => SubgraphDefinition[],\n _httpServer: http.Server,\n contextFactory: GatewayContextFactory<Context>,\n ): Promise<FetchHandler> {\n if (this.#supergraphApp) {\n throw new Error(\"Supergraph is already running\");\n }\n this.#getSubgraphs = getSubgraphs;\n this.#supergraphContextFactory = contextFactory;\n this.#supergraphApp = await buildGatewayApp(\n getSubgraphs(),\n contextFactory,\n this.#logger,\n );\n\n // Capture `this` so the returned handler always delegates to the *current*\n // #supergraphApp, allowing updateSupergraph() to swap it atomically.\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const adapter = this;\n return (request: Request): Promise<Response> => {\n if (!adapter.#supergraphApp) {\n return Promise.resolve(\n new Response(\"Gateway not ready\", { status: 503 }),\n );\n }\n return requestAls.run(request, () =>\n injectRequest(adapter.#supergraphApp!, request),\n );\n };\n }\n\n async updateSupergraph(): Promise<void> {\n if (!this.#getSubgraphs || !this.#supergraphContextFactory) return;\n const newApp = await buildGatewayApp(\n this.#getSubgraphs(),\n this.#supergraphContextFactory,\n this.#logger,\n );\n const oldApp = this.#supergraphApp;\n // Swap atomically — in-flight requests on the old app finish normally.\n this.#supergraphApp = newApp;\n if (oldApp) await oldApp.close();\n }\n\n async stop(): Promise<void> {\n await Promise.all(this.#subgraphApps.map((app) => app.close()));\n this.#subgraphApps.length = 0;\n if (this.#supergraphApp) {\n await this.#supergraphApp.close();\n this.#supergraphApp = null;\n }\n this.#getSubgraphs = null;\n this.#supergraphContextFactory = null;\n }\n}\n\n// ── Fastify instance factories ────────────────────────────────────────────────\n\nfunction makeContextFn(\n contextFactory: GatewayContextFactory<Context>,\n logger: ILogger,\n) {\n return (_req: FastifyRequest, _reply: FastifyReply) => {\n const request = requestAls.getStore();\n if (!request) {\n logger.error(\"[mercurius] No Fetch Request in AsyncLocalStorage\");\n throw new Error(\"No Fetch Request in AsyncLocalStorage\");\n }\n return contextFactory(request);\n };\n}\n\nasync function buildMercuriusApp(\n schema: GraphQLSchema,\n contextFactory: GatewayContextFactory<Context>,\n logger: ILogger,\n): Promise<FastifyInstance> {\n const app = Fastify({ logger: false });\n\n await app.register(mercurius, {\n schema,\n graphiql: false,\n context: makeContextFn(contextFactory, logger),\n // Override _Service.sdl to rewrite \"type Query/Mutation/Subscription {\"\n // as \"extend type … {\" so that @mercuriusjs/gateway v5 (which follows the\n // Federation v1 convention of using extensionTypeMap) correctly maps root\n // operation fields to this service during query planning.\n resolvers: {\n _Service: {\n sdl: (parent: { sdl?: string }) =>\n (parent.sdl ?? \"\").replace(\n /\\btype\\s+(Query|Mutation|Subscription)\\s*\\{/g,\n \"extend type $1 {\",\n ),\n },\n },\n } satisfies MercuriusOptions);\n\n await app.ready();\n return app;\n}\n\n/**\n * Builds a Mercurius federation gateway that composes the given subgraph\n * services. Each service URL must be reachable so that the gateway can fetch\n * its SDL via `_service { sdl }` (Apollo Federation protocol).\n */\nasync function buildGatewayApp(\n subgraphs: SubgraphDefinition[],\n contextFactory: GatewayContextFactory<Context>,\n logger: ILogger,\n): Promise<FastifyInstance> {\n const app = Fastify({ logger: false });\n\n await app.register(mercuriusGatewayPlugin, {\n gateway: {\n services: subgraphs.map((s) => ({ name: s.name, url: s.url })),\n },\n graphiql: false,\n context: makeContextFn(contextFactory, logger),\n });\n\n await app.ready();\n return app;\n}\n\n// ── Fetch API bridge ──────────────────────────────────────────────────────────\n\nfunction buildFetchHandler(app: FastifyInstance): FetchHandler {\n return (request: Request): Promise<Response> =>\n requestAls.run(request, () => injectRequest(app, request));\n}\n\nasync function injectRequest(\n app: FastifyInstance,\n request: Request,\n): Promise<Response> {\n const body =\n request.method !== \"GET\" && request.method !== \"HEAD\"\n ? await request.text()\n : undefined;\n\n const headers: Record<string, string> = {};\n request.headers.forEach((value, key) => {\n headers[key] = value;\n });\n\n const response = await app.inject({\n method: request.method as\n | \"DELETE\"\n | \"GET\"\n | \"HEAD\"\n | \"OPTIONS\"\n | \"PATCH\"\n | \"POST\"\n | \"PUT\",\n url: \"/graphql\",\n headers,\n payload: body,\n });\n\n const responseHeaders: Record<string, string> = {};\n for (const [key, value] of Object.entries(response.headers)) {\n if (value !== undefined) responseHeaders[key] = String(value);\n }\n\n return new Response(response.payload, {\n status: response.statusCode,\n headers: responseHeaders,\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AA6BA,MAAM,aAAa,IAAI,kBAA2B;AAQlD,MAAM,yBACJ;AAEF,IAAa,0BAAb,MAAyE;CACvE;CACA,gBAA4C,CAAC;CAE7C,iBAAyC;CACzC,gBAAqD;CACrD,4BAAmE;CAEnE,YAAY,QAAiB;EAC3B,KAAK,UAAU;CACjB;CAEA,MAAM,MAAM,aAAyC,CAGrD;CAEA,MAAM,cACJ,QACA,gBACuB;EACvB,MAAM,MAAM,MAAM,kBAAkB,QAAQ,gBAAgB,KAAK,OAAO;EACxE,KAAK,cAAc,KAAK,GAAG;EAC3B,OAAO,kBAAkB,GAAG;CAC9B;CAEA,MAAM,wBACJ,cACA,aACA,gBACuB;EACvB,IAAI,KAAK,gBACP,MAAM,IAAI,MAAM,+BAA+B;EAEjD,KAAK,gBAAgB;EACrB,KAAK,4BAA4B;EACjC,KAAK,iBAAiB,MAAM,gBAC1B,aAAa,GACb,gBACA,KAAK,OACP;EAKA,MAAM,UAAU;EAChB,QAAQ,YAAwC;GAC9C,IAAI,CAAC,QAAQ,gBACX,OAAO,QAAQ,QACb,IAAI,S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AM,IAAI,SAAS,wBAAwB;EACzC,SAAS,EACP,UAAU,UAAU,KAAK,OAAO;GAAE,MAAM,EAAE;GAAM,KAAK,EAAE;EAAI,EAAE,EAC/D;EACA,UAAU;EACV,SAAS,cAAc,gBAAgB,MAAM;CAC/C,CAAC;CAED,MAAM,IAAI,MAAM;CAChB,OAAO;AACT;AAIA,SAAS,kBAAkB,KAAoC;CAC7D,QAAQ,YACN,WAAW,IAAI,eAAe,cAAc,KAAK,OAAO,CAAC;AAC7D;AAEA,eAAe,cACb,KACA,SACmB;CACnB,MAAM,OACJ,QAAQ,WAAW,SAAS,QAAQ,WAAW,SAC3C,MAAM,QAAQ,KAAK,IACnB,KAAA;CAEN,MAAM,UAAkC,CAAC;CACzC,QAAQ,QAAQ,SAAS,OAAO,QAAQ;EACtC,QAAQ,OAAO;CACjB,CAAC;CAED,MAAM,WAAW,MAAM,IAAI,OAAO;EAChC,QAAQ,QAAQ;EAQhB,KAAK;EACL;EACA,SAAS;CACX,CAAC;CAED,MAAM,kBAA0C,CAAC;CACjD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,SAAS,OAAO,GACxD,IAAI,UAAU,KAAA,GAAW,gBAAgB,OAAO,OAAO,KAAK;CAG9D,OAAO,IAAI,SAAS,SAAS,SAAS;EACpC,QAAQ,SAAS;EACjB,SAAS;CACX,CAAC;AACH","debug_id":"5f791eb2-83b0-5fbd-a834-cc764eb2823a"}
@@ -1,15 +1,14 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="90361ed3-8d11-5317-8905-e79cd3599c85")}catch(e){}}();
3
- import { t as normalizePath } from "./path-normalize-DWWFLiy6.mjs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d226a728-a3eb-552f-946c-524e8548f295")}catch(e){}}();
3
+ import { n as normalizePath, t as runNodeHandler } from "./run-node-handler-CQjyjOuN.mjs";
4
4
  import path from "node:path";
5
5
  import { match } from "path-to-regexp";
6
6
  import { Readable } from "node:stream";
7
- import fs from "node:fs";
7
+ import nodeFs from "node:fs";
8
8
  import http from "node:http";
9
9
  import https from "node:https";
10
10
  import bodyParser from "body-parser";
11
11
  import cors from "cors";
12
- import devcert from "devcert";
13
12
  import expressLib, { Router } from "express";
14
13
  //#region src/graphql/gateway/adapter-http-express.ts
15
14
  var ExpressHttpAdapter = class {
@@ -93,7 +92,7 @@ var ExpressHttpAdapter = class {
93
92
  const matched = entry.matcher(pathname);
94
93
  if (!matched) continue;
95
94
  req.params = matched.params;
96
- entry.handler(req, res, entry.rawBody ? void 0 : req.body);
95
+ runNodeHandler(entry.handler, req, res, entry.rawBody ? void 0 : req.body);
97
96
  return true;
98
97
  }
99
98
  next();
@@ -135,9 +134,10 @@ var ExpressHttpAdapter = class {
135
134
  this.#routes.delete(handle);
136
135
  }
137
136
  }
138
- async listen(port, tls) {
137
+ async listen(port, tls, host) {
139
138
  let server;
140
139
  if (tls === true) {
140
+ const { default: devcert } = await import("devcert");
141
141
  const { cert, key } = await devcert.certificateFor("localhost");
142
142
  if (!cert || !key) throw new Error("Invalid certificate generated");
143
143
  server = https.createServer({
@@ -147,8 +147,8 @@ var ExpressHttpAdapter = class {
147
147
  } else if (tls && "keyPath" in tls) {
148
148
  const currentDir = process.cwd();
149
149
  server = https.createServer({
150
- key: fs.readFileSync(path.join(currentDir, tls.keyPath)),
151
- cert: fs.readFileSync(path.join(currentDir, tls.certPath))
150
+ key: nodeFs.readFileSync(path.join(currentDir, tls.keyPath)),
151
+ cert: nodeFs.readFileSync(path.join(currentDir, tls.certPath))
152
152
  }, this.#app);
153
153
  } else if (tls && "cert" in tls) server = https.createServer({
154
154
  cert: tls.cert,
@@ -157,7 +157,7 @@ var ExpressHttpAdapter = class {
157
157
  else server = http.createServer(this.#app);
158
158
  return new Promise((resolve, reject) => {
159
159
  server.once("error", reject);
160
- server.listen(port, () => {
160
+ server.listen(port, host, () => {
161
161
  server.off("error", reject);
162
162
  resolve(server);
163
163
  });
@@ -235,5 +235,5 @@ function createExpressHttpAdapter(existingApp) {
235
235
  //#endregion
236
236
  export { createExpressHttpAdapter };
237
237
 
238
- //# sourceMappingURL=adapter-http-express-54gdI9bu.mjs.map
239
- //# debugId=90361ed3-8d11-5317-8905-e79cd3599c85
238
+ //# sourceMappingURL=adapter-http-express-78KD77cI.mjs.map
239
+ //# debugId=d226a728-a3eb-552f-946c-524e8548f295
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-http-express-78KD77cI.mjs","sources":["../src/graphql/gateway/adapter-http-express.ts"],"sourcesContent":["import bodyParser from \"body-parser\";\nimport cors from \"cors\";\nimport type { CorsOptions } from \"cors\";\nimport type express from \"express\";\nimport type { Express } from \"express\";\nimport { Router } from \"express\";\nimport expressLib from \"express\";\nimport type { IRouter } from \"express\";\nimport fs from \"node:fs\";\nimport http from \"node:http\";\nimport https from \"node:https\";\nimport path from \"node:path\";\nimport { Readable } from \"node:stream\";\nimport type { ReadableStream as WebReadableStream } from \"node:stream/web\";\nimport { match, type MatchFunction, type ParamData } from \"path-to-regexp\";\nimport type {\n FetchHandler,\n HttpMethod,\n IHttpAdapter,\n NodeRouteOptions,\n AdapterRouteHandle,\n TlsOptions,\n} from \"./types.js\";\nimport { normalizePath } from \"./path-normalize.js\";\nimport { runNodeHandler, type NodeHandler } from \"./run-node-handler.js\";\n\ntype GetHandler = (r: Request) => Response | Promise<Response>;\n\ntype RouteEntry =\n | {\n kind: \"fetch\";\n path: string;\n matcher: MatchFunction<ParamData>;\n prefix: boolean;\n handler: FetchHandler;\n }\n | {\n kind: \"get\";\n path: string;\n matcher: MatchFunction<ParamData>;\n handler: GetHandler;\n }\n | {\n kind: \"node\";\n method: string;\n path: string;\n matcher: MatchFunction<ParamData>;\n handler: NodeHandler;\n /** Dispatched ahead of the body parsers, with the stream unread. */\n rawBody: boolean;\n };\n\nexport class ExpressHttpAdapter implements IHttpAdapter {\n readonly #app: Express;\n readonly #router: IRouter;\n\n /**\n * Every route lives in this registry and is served by one\n * permanently-registered dispatcher (installed by setupMiddleware), because\n * Express 4 has no route-removal API: routes registered directly on the\n * app or router can never be taken back. Entries iterate in registration\n * order; mounting a path that already holds a route of the same kind (and\n * method, for node routes) replaces the old entry, so re-mounting is\n * last-write-wins without accumulating.\n */\n readonly #routes = new Map<number, RouteEntry>();\n #nextHandle = 0;\n\n constructor(existingApp?: Express) {\n this.#app = existingApp ?? expressLib();\n this.#router = Router();\n this.#app.use(this.#router);\n }\n\n setupSentryErrorHandler(sentry: object): void {\n const s = sentry as {\n setupExpressErrorHandler(app: Express): void;\n };\n s.setupExpressErrorHandler(this.#app);\n }\n\n get handle(): unknown {\n return this.#app;\n }\n\n mountRawMiddleware(middleware: unknown): void {\n // Connect/Express middleware shape; the caller owns its typing.\n this.#app.use(middleware as express.RequestHandler);\n }\n\n mountNodeRoute(\n method: HttpMethod,\n path: string,\n handler: (\n req: http.IncomingMessage,\n res: http.ServerResponse,\n body?: unknown,\n ) => void | Promise<void>,\n { rawBody = false, prefix = false }: NodeRouteOptions = {},\n ): AdapterRouteHandle {\n this.#replaceDuplicates(\"node\", path, method.toUpperCase());\n const handle = this.#nextHandle++;\n this.#routes.set(handle, {\n kind: \"node\",\n method: method.toUpperCase(),\n path,\n matcher: match(normalizePath(path), { end: !prefix }),\n rawBody,\n handler,\n });\n return { dispose: () => this.#routes.delete(handle) };\n }\n\n setupMiddleware({\n corsOptions,\n bodyLimit = \"50mb\",\n }: {\n corsOptions?: CorsOptions;\n bodyLimit?: string;\n }): void {\n this.#router.use(cors(corsOptions));\n\n // Ahead of the parsers: a raw route's whole point is that nothing has read\n // the stream. Behind them, `req` is a consumed stream and only a\n // re-encoded `req.body` survives — which cannot carry a signature over the\n // octets the client actually sent.\n this.#router.use((req, res, next) => {\n this.#dispatchNodeRoute(req, res, next, true);\n });\n\n this.#router.use(bodyParser.json({ limit: bodyLimit }));\n this.#router.use(\n bodyParser.urlencoded({ extended: true, limit: bodyLimit }),\n );\n\n // The single dispatch point for every registered route, registered\n // AFTER the body parsers so node routes receive a parsed req.body.\n // A request matching no route falls through to app-level middleware\n // (mountRawMiddleware) and then Express's default 404.\n this.#router.use((req, res, next) => {\n const pathname = req.path;\n\n // Node routes first, then GET routes, then Fetch mounts — the same\n // order the Fastify adapter uses. A node route is the most specific\n // registration there is (method plus exact path), while a Fetch mount is\n // often a prefix; letting the prefix win would silently shadow an exact\n // route, and would do it in only one of the two adapters.\n if (this.#dispatchNodeRoute(req, res, () => undefined, false)) return;\n\n if (req.method === \"GET\" || req.method === \"HEAD\") {\n for (const entry of this.#routes.values()) {\n if (entry.kind !== \"get\" || !entry.matcher(pathname)) continue;\n this.#serveGetEntry(entry, req, res);\n return;\n }\n }\n\n for (const entry of this.#routes.values()) {\n if (entry.kind !== \"fetch\" || !entry.matcher(pathname)) continue;\n this.#serveFetchHandler(entry.handler, req, res, next);\n return;\n }\n\n next();\n });\n }\n\n /**\n * Serves the first node route matching this request, or calls `next()`.\n * `raw` selects which half of the registry to consider, so the two passes —\n * one before the body parsers, one after — never serve the same route twice.\n */\n #dispatchNodeRoute(\n req: express.Request,\n res: express.Response,\n next: express.NextFunction,\n raw: boolean,\n ): boolean {\n const pathname = req.path;\n for (const entry of this.#routes.values()) {\n if (entry.kind !== \"node\") continue;\n if (entry.rawBody !== raw) continue;\n if (entry.method !== req.method) continue;\n const matched = entry.matcher(pathname);\n if (!matched) continue;\n req.params = matched.params as Record<string, string>;\n runNodeHandler(\n entry.handler,\n req,\n res,\n entry.rawBody ? undefined : req.body,\n );\n return true;\n }\n next();\n return false;\n }\n\n mount(\n path: string,\n handler: FetchHandler,\n { prefix, exact }: { prefix?: boolean; exact?: boolean } = {},\n ): AdapterRouteHandle {\n // `exact` never meant exact: it selected prefix matching. Kept as an alias\n // so existing callers keep working while the name is retired.\n const asPrefix = prefix ?? exact ?? false;\n this.#replaceDuplicates(\"fetch\", path);\n const handle = this.#nextHandle++;\n this.#routes.set(handle, {\n kind: \"fetch\",\n path,\n matcher: match(normalizePath(path), { end: !asPrefix }),\n prefix: asPrefix,\n handler,\n });\n return { dispose: () => this.#routes.delete(handle) };\n }\n\n getRoute(\n path: string,\n handler: (request: Request) => Response | Promise<Response>,\n ): AdapterRouteHandle {\n this.#replaceDuplicates(\"get\", path);\n const handle = this.#nextHandle++;\n this.#routes.set(handle, {\n kind: \"get\",\n path,\n matcher: match(normalizePath(path)),\n handler,\n });\n return { dispose: () => this.#routes.delete(handle) };\n }\n\n /**\n * Drop any existing entry the new registration would duplicate (same kind\n * and path, plus method for node routes) so a re-mount replaces instead of\n * shadowing. Map iteration tolerates concurrent deletion.\n */\n #replaceDuplicates(\n kind: RouteEntry[\"kind\"],\n path: string,\n method?: string,\n ): void {\n for (const [handle, entry] of this.#routes) {\n if (entry.kind !== kind || entry.path !== path) continue;\n if (kind === \"node\" && entry.kind === \"node\" && entry.method !== method) {\n continue;\n }\n this.#routes.delete(handle);\n }\n }\n\n async listen(\n port: number,\n tls?: TlsOptions,\n host?: string,\n ): Promise<http.Server> {\n let server: http.Server;\n\n if (tls === true) {\n // Only for local HTTPS, and it does work as it loads.\n const { default: devcert } = await import(\"devcert\");\n const { cert, key } = (await devcert.certificateFor(\"localhost\")) as {\n cert: Buffer;\n key: Buffer;\n };\n if (!cert || !key) {\n throw new Error(\"Invalid certificate generated\");\n }\n server = https.createServer({ cert, key }, this.#app);\n } else if (tls && \"keyPath\" in tls) {\n const currentDir = process.cwd();\n server = https.createServer(\n {\n key: fs.readFileSync(path.join(currentDir, tls.keyPath)),\n cert: fs.readFileSync(path.join(currentDir, tls.certPath)),\n },\n this.#app,\n );\n } else if (tls && \"cert\" in tls) {\n server = https.createServer({ cert: tls.cert, key: tls.key }, this.#app);\n } else {\n server = http.createServer(this.#app);\n }\n\n return new Promise<http.Server>((resolve, reject) => {\n server.once(\"error\", reject);\n server.listen(port, host, () => {\n server.off(\"error\", reject);\n resolve(server);\n });\n });\n }\n\n #serveFetchHandler(\n handler: FetchHandler,\n req: express.Request,\n res: express.Response,\n next: express.NextFunction,\n ): void {\n // Build the full URL for the Fetch Request\n const protocol = req.protocol;\n const host = req.get(\"host\") ?? \"localhost\";\n const url = `${protocol}://${host}${req.originalUrl}`;\n\n // Convert Node.js incoming headers to Fetch Headers\n const headers = new Headers();\n for (const [key, value] of Object.entries(req.headers)) {\n if (typeof value === \"string\") {\n headers.set(key, value);\n } else if (Array.isArray(value)) {\n headers.set(key, value.join(\", \"));\n }\n }\n\n // bodyParser has already run, so req.body is a parsed JS value.\n // Re-serialize it so the Fetch Request body stream is readable.\n let body: string | undefined;\n if (\n req.method !== \"GET\" &&\n req.method !== \"HEAD\" &&\n req.body !== undefined\n ) {\n body = JSON.stringify(req.body);\n }\n\n const fetchRequest = new Request(url, {\n method: req.method,\n headers,\n body,\n });\n\n Promise.resolve(handler(fetchRequest))\n .then(async (response) => {\n res.status(response.status);\n response.headers.forEach((value, key) => {\n res.setHeader(key, value);\n });\n if (response.body === null) {\n res.send(await response.text());\n return;\n }\n // Stream the body to the socket instead of awaiting .text(): a\n // stream-backed body (e.g. graphql-sse) only closes when the\n // subscription completes, so awaiting would hang the request.\n // `response.body` is typed against the global (lib) ReadableStream\n // declaration, while Readable.fromWeb wants node:stream/web's; at\n // runtime they are the same stream, so the cast is safe.\n const bodyStream = response.body as WebReadableStream;\n const nodeStream = Readable.fromWeb(bodyStream);\n req.on(\"close\", () => {\n // The client went away mid-stream; stop pulling from the source.\n nodeStream.destroy();\n });\n nodeStream.on(\"error\", (err) => {\n if (res.headersSent) {\n // The response has already started; nothing left to say.\n res.destroy();\n } else {\n next(err);\n }\n });\n nodeStream.pipe(res);\n })\n .catch(next);\n }\n\n #serveGetEntry(\n entry: Extract<RouteEntry, { kind: \"get\" }>,\n req: express.Request,\n res: express.Response,\n ): void {\n const protocol = req.protocol;\n const host = req.get(\"host\") ?? \"localhost\";\n const url = `${protocol}://${host}${req.originalUrl}`;\n const headers = new Headers();\n for (const [key, value] of Object.entries(req.headers)) {\n if (typeof value === \"string\") {\n headers.set(key, value);\n } else if (Array.isArray(value)) {\n headers.set(key, value.join(\", \"));\n }\n }\n // GET is forced (matching the pre-refactor behavior, which also\n // normalized HEAD requests through the GET route handler).\n const fetchRequest = new Request(url, { method: \"GET\", headers });\n Promise.resolve(entry.handler(fetchRequest))\n .then(async (response) => {\n res.status(response.status);\n response.headers.forEach((value, key) => {\n res.setHeader(key, value);\n });\n if (response.body === null) {\n res.send(await response.text());\n return;\n }\n // Stream the body to the socket instead of awaiting .text(): a\n // stream-backed body (e.g. graphql-sse) only closes when the\n // subscription completes, so awaiting would hang the request.\n // `response.body` is typed against the global (lib) ReadableStream\n // declaration, while Readable.fromWeb wants node:stream/web's; at\n // runtime they are the same stream, so the cast is safe.\n const bodyStream = response.body as WebReadableStream;\n const nodeStream = Readable.fromWeb(bodyStream);\n req.on(\"close\", () => {\n // The client went away mid-stream; stop pulling from the source.\n nodeStream.destroy();\n });\n nodeStream.on(\"error\", (err) => {\n if (res.headersSent) {\n // The response has already started; nothing left to say.\n res.destroy();\n } else {\n res.status(500).send(String(err));\n }\n });\n nodeStream.pipe(res);\n })\n .catch((err: unknown) => {\n res.status(500).send(String(err));\n });\n }\n}\n\nexport function createExpressHttpAdapter(existingApp?: Express): {\n adapter: IHttpAdapter;\n} {\n return { adapter: new ExpressHttpAdapter(existingApp) };\n}\n"],"names":["fs"],"mappings":";;;;;;;;;;;;;AAoDA,IAAa,qBAAb,MAAwD;CACtD;CACA;;;;;;;;;;CAWA,0BAAmB,IAAI,IAAwB;CAC/C,cAAc;CAEd,YAAY,aAAuB;EACjC,KAAK,OAAO,eAAe,WAAW;EACtC,KAAK,U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MAAM,KAAK,IAAI,CAAC;EAKrC,MAAM,eAAe,IAAI,QAAQ,KAAK;GAAE,QAAQ;GAAO;EAAQ,CAAC;EAChE,QAAQ,QAAQ,MAAM,QAAQ,YAAY,CAAC,CAAC,CACzC,KAAK,OAAO,aAAa;GACxB,IAAI,OAAO,SAAS,MAAM;GAC1B,SAAS,QAAQ,SAAS,OAAO,QAAQ;IACvC,IAAI,UAAU,KAAK,KAAK;GAC1B,CAAC;GACD,IAAI,SAAS,SAAS,MAAM;IAC1B,IAAI,KAAK,MAAM,SAAS,KAAK,CAAC;IAC9B;GACF;GAOA,MAAM,aAAa,SAAS;GAC5B,MAAM,aAAa,SAAS,QAAQ,UAAU;GAC9C,IAAI,GAAG,eAAe;IAEpB,WAAW,QAAQ;GACrB,CAAC;GACD,WAAW,GAAG,UAAU,QAAQ;IAC9B,IAAI,IAAI,aAEN,IAAI,QAAQ;SAEZ,IAAI,OAAO,GAAG,CAAC,CAAC,KAAK,OAAO,GAAG,CAAC;GAEpC,CAAC;GACD,WAAW,KAAK,GAAG;EACrB,CAAC,CAAC,CACD,OAAO,QAAiB;GACvB,IAAI,OAAO,GAAG,CAAC,CAAC,KAAK,OAAO,GAAG,CAAC;EAClC,CAAC;CACL;AACF;AAEA,SAAgB,yBAAyB,aAEvC;CACA,OAAO,EAAE,SAAS,IAAI,mBAAmB,WAAW,EAAE;AACxD","debug_id":"d226a728-a3eb-552f-946c-524e8548f295"}
@@ -1,14 +1,13 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a9dc57df-8ede-54a4-8a09-14b3ff82f44d")}catch(e){}}();
3
- import { t as normalizePath } from "./path-normalize-DWWFLiy6.mjs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6dc53a17-d7ba-55cb-86a4-0f5cc5decc46")}catch(e){}}();
3
+ import { n as normalizePath, t as runNodeHandler } from "./run-node-handler-CQjyjOuN.mjs";
4
4
  import path from "node:path";
5
5
  import { match } from "path-to-regexp";
6
6
  import { Readable } from "node:stream";
7
- import fs from "node:fs";
7
+ import nodeFs from "node:fs";
8
8
  import http from "node:http";
9
9
  import https from "node:https";
10
10
  import Fastify from "fastify";
11
- import devcert from "devcert";
12
11
  import fastifyCors from "@fastify/cors";
13
12
  import fastifyFormbody from "@fastify/formbody";
14
13
  import fastifyMiddie from "@fastify/middie";
@@ -87,9 +86,10 @@ var FastifyHttpAdapter = class {
87
86
  if (!this.#instance) return;
88
87
  sentry.setupFastifyErrorHandler(this.#instance);
89
88
  }
90
- async listen(port, tls) {
89
+ async listen(port, tls, host) {
91
90
  let httpServer;
92
91
  if (tls === true) {
92
+ const { default: devcert } = await import("devcert");
93
93
  const { cert, key } = await devcert.certificateFor("localhost");
94
94
  if (!cert || !key) throw new Error("Invalid certificate generated");
95
95
  httpServer = https.createServer({
@@ -99,20 +99,21 @@ var FastifyHttpAdapter = class {
99
99
  } else if (tls && "keyPath" in tls) {
100
100
  const cwd = process.cwd();
101
101
  httpServer = https.createServer({
102
- key: fs.readFileSync(path.join(cwd, tls.keyPath)),
103
- cert: fs.readFileSync(path.join(cwd, tls.certPath))
102
+ key: nodeFs.readFileSync(path.join(cwd, tls.keyPath)),
103
+ cert: nodeFs.readFileSync(path.join(cwd, tls.certPath))
104
104
  });
105
105
  } else if (tls && "cert" in tls) httpServer = https.createServer({
106
106
  cert: tls.cert,
107
107
  key: tls.key
108
108
  });
109
109
  else httpServer = http.createServer();
110
+ const bodyLimit = this.#setupOps.find((op) => op.kind === "cors")?.bodyLimit ?? 52428800;
110
111
  const instance = Fastify({
111
112
  serverFactory: (handler) => {
112
113
  httpServer.on("request", handler);
113
114
  return httpServer;
114
115
  },
115
- bodyLimit: this.#setupOps.find((op) => op.kind === "cors")?.bodyLimit ?? 52428800,
116
+ bodyLimit,
116
117
  logger: false
117
118
  });
118
119
  this.#instance = instance;
@@ -128,7 +129,7 @@ var FastifyHttpAdapter = class {
128
129
  }
129
130
  req.raw.params = claimed.params;
130
131
  reply.hijack();
131
- claimed.route.handler(req.raw, reply.raw, void 0);
132
+ runNodeHandler(claimed.route.handler, req.raw, reply.raw, void 0);
132
133
  });
133
134
  instance.route({
134
135
  method: [
@@ -145,7 +146,7 @@ var FastifyHttpAdapter = class {
145
146
  await instance.ready();
146
147
  return new Promise((resolve, reject) => {
147
148
  httpServer.once("error", reject);
148
- httpServer.listen(port, () => {
149
+ httpServer.listen(port, host, () => {
149
150
  httpServer.off("error", reject);
150
151
  resolve(httpServer);
151
152
  });
@@ -176,7 +177,7 @@ var FastifyHttpAdapter = class {
176
177
  if (node) {
177
178
  req.raw.params = node.params;
178
179
  reply.hijack();
179
- node.route.handler(req.raw, reply.raw, req.body);
180
+ runNodeHandler(node.route.handler, req.raw, reply.raw, req.body);
180
181
  return;
181
182
  }
182
183
  if (method === "GET") {
@@ -239,5 +240,5 @@ function createFastifyHttpAdapter() {
239
240
  //#endregion
240
241
  export { createFastifyHttpAdapter };
241
242
 
242
- //# sourceMappingURL=adapter-http-fastify-DmccBVOe.mjs.map
243
- //# debugId=a9dc57df-8ede-54a4-8a09-14b3ff82f44d
243
+ //# sourceMappingURL=adapter-http-fastify-Dk7aT_xw.mjs.map
244
+ //# debugId=6dc53a17-d7ba-55cb-86a4-0f5cc5decc46
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-http-fastify-Dk7aT_xw.mjs","sources":["../src/graphql/gateway/adapter-http-fastify.ts"],"sourcesContent":["import fastifyCors from \"@fastify/cors\";\nimport fastifyFormbody from \"@fastify/formbody\";\nimport fastifyMiddie from \"@fastify/middie\";\nimport type { CorsOptions } from \"cors\";\nimport Fastify from \"fastify\";\nimport type { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\";\nimport fs from \"node:fs\";\nimport http from \"node:http\";\nimport https from \"node:https\";\nimport nodePath from \"node:path\";\nimport { Readable } from \"node:stream\";\nimport type { ReadableStream as WebReadableStream } from \"node:stream/web\";\nimport { match, type MatchFunction, type ParamData } from \"path-to-regexp\";\nimport type {\n FetchHandler,\n HttpMethod,\n IHttpAdapter,\n NodeRouteOptions,\n AdapterRouteHandle,\n TlsOptions,\n} from \"./types.js\";\nimport { normalizePath } from \"./path-normalize.js\";\nimport { runNodeHandler, type NodeHandler } from \"./run-node-handler.js\";\n\n/** Parses body-limit strings like \"50mb\" to bytes. */\nfunction parseBodyLimit(limit: string): number {\n const m = /^(\\d+(?:\\.\\d+)?)\\s*(b|kb|mb|gb)?$/i.exec(limit.trim());\n if (!m) return 52_428_800; // 50 MB fallback\n const n = parseFloat(m[1]);\n const units: Record<string, number> = {\n b: 1,\n kb: 1_024,\n mb: 1_048_576,\n gb: 1_073_741_824,\n };\n return Math.round(n * (units[(m[2] ?? \"b\").toLowerCase()] ?? 1));\n}\n\ntype FetchEntry = {\n path: string;\n handler: FetchHandler;\n matcher: MatchFunction<ParamData>;\n prefix: boolean;\n};\n\ntype GetEntry = {\n path: string;\n handler: (r: Request) => Response | Promise<Response>;\n matcher: MatchFunction<ParamData>;\n};\n\ntype NodeEntry = {\n path: string;\n method: HttpMethod;\n matcher: MatchFunction<ParamData>;\n handler: NodeHandler;\n /** Claimed in the onRequest hook, before any body parsing. */\n rawBody: boolean;\n};\n\n// Pre-listen configuration ops (need the Fastify instance to apply).\ntype SetupOp =\n | { kind: \"cors\"; options?: CorsOptions; bodyLimit: number }\n | { kind: \"middie\"; middleware: unknown };\n\nexport class FastifyHttpAdapter implements IHttpAdapter {\n // Dispatch maps, keyed by route handle and iterated in registration\n // order — populated at any time (before or after listen). Mounting a\n // path that already holds a route of the same kind (and method, for\n // node routes) replaces the old entry, so re-mounting is last-write-\n // wins without accumulating; a handle's dispose() removes its own entry.\n readonly #fetchRoutes = new Map<number, FetchEntry>();\n readonly #getRoutes = new Map<number, GetEntry>();\n readonly #nodeRoutes = new Map<number, NodeEntry>();\n #nextHandle = 0;\n\n // Ops that need the Fastify instance (CORS config, Connect middleware).\n readonly #setupOps: SetupOp[] = [];\n\n #instance: FastifyInstance | undefined;\n\n get handle(): unknown {\n return this.#instance;\n }\n\n setupMiddleware({\n corsOptions,\n bodyLimit = \"50mb\",\n }: {\n corsOptions?: CorsOptions;\n bodyLimit?: string;\n }): void {\n this.#setupOps.push({\n kind: \"cors\",\n options: corsOptions,\n bodyLimit: parseBodyLimit(bodyLimit),\n });\n }\n\n mount(\n path: string,\n handler: FetchHandler,\n { prefix, exact }: { prefix?: boolean; exact?: boolean } = {},\n ): AdapterRouteHandle {\n // `exact` never meant exact: it selected prefix matching. Kept as an alias\n // so existing callers keep working while the name is retired.\n const asPrefix = prefix ?? exact ?? false;\n for (const [handle, entry] of this.#fetchRoutes) {\n if (entry.path === path) this.#fetchRoutes.delete(handle);\n }\n const handle = this.#nextHandle++;\n this.#fetchRoutes.set(handle, {\n path,\n handler,\n matcher: match(normalizePath(path), { end: !asPrefix }),\n prefix: asPrefix,\n });\n return { dispose: () => this.#fetchRoutes.delete(handle) };\n }\n\n getRoute(\n path: string,\n handler: (r: Request) => Response | Promise<Response>,\n ): AdapterRouteHandle {\n for (const [handle, entry] of this.#getRoutes) {\n if (entry.path === path) this.#getRoutes.delete(handle);\n }\n const handle = this.#nextHandle++;\n this.#getRoutes.set(handle, {\n path,\n handler,\n matcher: match(normalizePath(path)),\n });\n return { dispose: () => this.#getRoutes.delete(handle) };\n }\n\n mountNodeRoute(\n method: HttpMethod,\n path: string,\n handler: NodeHandler,\n { rawBody = false, prefix = false }: NodeRouteOptions = {},\n ): AdapterRouteHandle {\n for (const [handle, entry] of this.#nodeRoutes) {\n if (entry.path === path && entry.method === method) {\n this.#nodeRoutes.delete(handle);\n }\n }\n const handle = this.#nextHandle++;\n this.#nodeRoutes.set(handle, {\n path,\n method,\n matcher: match(normalizePath(path), { end: !prefix }),\n handler,\n rawBody,\n });\n return { dispose: () => this.#nodeRoutes.delete(handle) };\n }\n\n mountRawMiddleware(middleware: unknown): void {\n if (this.#instance) {\n // @fastify/middie is always registered, so .use() is available post-listen.\n (\n this.#instance as FastifyInstance & {\n use(middleware: unknown): FastifyInstance;\n }\n ).use(middleware);\n } else {\n this.#setupOps.push({ kind: \"middie\", middleware });\n }\n }\n\n setupSentryErrorHandler(sentry: object): void {\n if (!this.#instance) return;\n const s = sentry as {\n setupFastifyErrorHandler(app: FastifyInstance): void;\n };\n s.setupFastifyErrorHandler(this.#instance);\n }\n\n async listen(\n port: number,\n tls?: TlsOptions,\n host?: string,\n ): Promise<http.Server> {\n let httpServer: http.Server;\n\n if (tls === true) {\n // Only for local HTTPS, and it does work as it loads.\n const { default: devcert } = await import(\"devcert\");\n const { cert, key } = (await devcert.certificateFor(\"localhost\")) as {\n cert: Buffer;\n key: Buffer;\n };\n if (!cert || !key) throw new Error(\"Invalid certificate generated\");\n httpServer = https.createServer({ cert, key });\n } else if (tls && \"keyPath\" in tls) {\n const cwd = process.cwd();\n httpServer = https.createServer({\n key: fs.readFileSync(nodePath.join(cwd, tls.keyPath)),\n cert: fs.readFileSync(nodePath.join(cwd, tls.certPath)),\n });\n } else if (tls && \"cert\" in tls) {\n httpServer = https.createServer({ cert: tls.cert, key: tls.key });\n } else {\n httpServer = http.createServer();\n }\n\n const corsOp = this.#setupOps.find(\n (op): op is Extract<SetupOp, { kind: \"cors\" }> => op.kind === \"cors\",\n );\n const bodyLimit = corsOp?.bodyLimit ?? 52_428_800;\n\n const instance = Fastify({\n serverFactory: (handler) => {\n httpServer.on(\"request\", handler);\n return httpServer;\n },\n bodyLimit,\n logger: false,\n });\n\n this.#instance = instance;\n\n // Always register middie first so .use() is available post-listen.\n await instance.register(fastifyMiddie);\n await instance.register(fastifyFormbody);\n\n for (const op of this.#setupOps) {\n if (op.kind === \"cors\") {\n await instance.register(\n fastifyCors,\n op.options as Parameters<typeof fastifyCors>[1],\n );\n } else {\n (\n instance as FastifyInstance & {\n use(middleware: unknown): FastifyInstance;\n }\n ).use(op.middleware);\n }\n }\n\n // Raw routes are claimed here, in the earliest hook there is: Fastify\n // parses the body before the handler runs, and it 415s an unknown content\n // type outright, so a route that needs the octets as sent cannot wait for\n // dispatch. `hijack()` takes the reply out of Fastify's lifecycle and the\n // handler owns the socket from here.\n instance.addHook(\"onRequest\", (req, reply, done) => {\n const claimed = this.#matchNodeRoute(req, true);\n if (!claimed) {\n done();\n return;\n }\n (req.raw as http.IncomingMessage & { params?: ParamData }).params =\n claimed.params;\n reply.hijack();\n runNodeHandler(claimed.route.handler, req.raw, reply.raw, undefined);\n });\n\n // Single catch-all route — all dispatching is done via the Maps above so\n // that routes registered after listen() are picked up automatically.\n // OPTIONS is excluded because @fastify/cors registers its own OPTIONS /*\n // handler for preflight; including it here would cause a duplicate-route\n // conflict at startup.\n instance.route({\n method: [\"DELETE\", \"GET\", \"HEAD\", \"PATCH\", \"POST\", \"PUT\"],\n url: \"/*\",\n handler: (req, reply) => this.#dispatch(req, reply),\n });\n\n await instance.ready();\n\n return new Promise<http.Server>((resolve, reject) => {\n httpServer.once(\"error\", reject);\n httpServer.listen(port, host, () => {\n httpServer.off(\"error\", reject);\n resolve(httpServer);\n });\n });\n }\n\n /**\n * Finds a node route for this request. `raw` selects which half of the\n * registry to consider: raw routes are claimed in the onRequest hook, the\n * rest in the catch-all handler once the body is parsed.\n */\n #matchNodeRoute(\n req: FastifyRequest,\n raw: boolean,\n ): { route: NodeEntry; params: ParamData } | undefined {\n const pathname = new URL(req.url, \"http://localhost\").pathname;\n const method = req.method.toUpperCase();\n for (const entry of this.#nodeRoutes.values()) {\n if (entry.rawBody !== raw) continue;\n if (entry.method !== method) continue;\n const result = entry.matcher(pathname);\n if (result) return { route: entry, params: result.params };\n }\n return undefined;\n }\n\n #dispatch(\n req: FastifyRequest,\n reply: FastifyReply,\n ): void | Promise<FastifyReply> {\n const pathname = new URL(req.url, \"http://localhost\").pathname;\n const method = req.method.toUpperCase() as\n | \"DELETE\"\n | \"GET\"\n | \"HEAD\"\n | \"PATCH\"\n | \"POST\"\n | \"PUT\";\n\n // 1. Node routes — path-to-regexp match + method, handler manages raw\n // response. Attach decoded params onto `req.raw` so downstream handlers\n // can read them via the same `req.params` API the Express adapter exposes.\n const node = this.#matchNodeRoute(req, false);\n if (node) {\n (req.raw as http.IncomingMessage & { params?: ParamData }).params =\n node.params;\n reply.hijack();\n runNodeHandler(node.route.handler, req.raw, reply.raw, req.body);\n return;\n }\n\n // 2. GET-specific routes (health, explorer, etc.).\n if (method === \"GET\") {\n for (const entry of this.#getRoutes.values()) {\n if (entry.matcher(pathname)) {\n return this.#serveGetEntry(entry, req, reply);\n }\n }\n }\n\n // 3. Fetch routes (GraphQL handlers, SSE, etc.).\n // Iterate in reverse so that the last-mounted handler wins when the same\n // path is mounted more than once (e.g. supergraph remount after reload).\n for (const entry of [...this.#fetchRoutes.values()].reverse()) {\n if (entry.matcher(pathname)) {\n return serveFetchHandler(entry.handler, req, reply);\n }\n }\n\n void reply.status(404).send({\n message: `Route ${req.method}:${pathname} not found`,\n error: \"Not Found\",\n statusCode: 404,\n });\n }\n\n async #serveGetEntry(\n entry: GetEntry,\n req: FastifyRequest,\n reply: FastifyReply,\n ): Promise<FastifyReply> {\n const url = buildUrl(req);\n const headers = buildHeaders(req);\n const fetchReq = new Request(url, { method: \"GET\", headers });\n const response = await entry.handler(fetchReq);\n writeResponse(reply, response);\n if (response.body === null) {\n return reply.send(await response.text());\n }\n // Stream the body instead of awaiting .text(): a stream-backed body\n // (e.g. graphql-sse) only closes when the subscription completes, so\n // awaiting would hang the request. Fastify tears the source down on\n // client disconnect and routes pre-header stream errors to the\n // error handler.\n // `response.body` is typed against the global (lib) ReadableStream\n // declaration, while Readable.fromWeb wants node:stream/web's; at\n // runtime they are the same stream, so the cast is safe.\n const bodyStream = response.body as WebReadableStream;\n return reply.send(Readable.fromWeb(bodyStream));\n }\n}\n\nasync function serveFetchHandler(\n handler: FetchHandler,\n req: FastifyRequest,\n reply: FastifyReply,\n): Promise<FastifyReply> {\n const url = buildUrl(req);\n const headers = buildHeaders(req);\n let body: string | undefined;\n if (req.method !== \"GET\" && req.method !== \"HEAD\" && req.body !== undefined) {\n body = JSON.stringify(req.body);\n }\n const response = await handler(\n new Request(url, { method: req.method, headers, body }),\n );\n writeResponse(reply, response);\n if (response.body === null) {\n return reply.send(await response.text());\n }\n // Stream the body instead of awaiting .text(): a stream-backed body\n // (e.g. graphql-sse) only closes when the subscription completes, so\n // awaiting would hang the request. Fastify tears the source down on\n // client disconnect and routes pre-header stream errors to the\n // error handler.\n // `response.body` is typed against the global (lib) ReadableStream\n // declaration, while Readable.fromWeb wants node:stream/web's; at\n // runtime they are the same stream, so the cast is safe.\n const bodyStream = response.body as WebReadableStream;\n return reply.send(Readable.fromWeb(bodyStream));\n}\n\nfunction buildUrl(req: FastifyRequest): string {\n const protocol = req.protocol;\n const host = req.headers.host ?? \"localhost\";\n return `${protocol}://${host}${req.url}`;\n}\n\nfunction buildHeaders(req: FastifyRequest): Headers {\n const headers = new Headers();\n for (const [key, value] of Object.entries(req.headers)) {\n if (typeof value === \"string\") {\n headers.set(key, value);\n } else if (Array.isArray(value)) {\n headers.set(key, value.join(\", \"));\n }\n }\n return headers;\n}\n\nfunction writeResponse(reply: FastifyReply, response: Response): void {\n reply.statusCode = response.status;\n response.headers.forEach((value, key) => {\n reply.header(key, value);\n });\n}\n\nexport function createFastifyHttpAdapter(): { adapter: IHttpAdapter } {\n return { adapter: new FastifyHttpAdapter() };\n}\n"],"names":["fs","nodePath"],"mappings":";;;;;;;;;;;;;;;AAyBA,SAAS,eAAe,OAAuB;CAC7C,MAAM,IAAI,qCAAqC,KAAK,MAAM,KAAK,CAAC;CAChE,IAAI,CAAC,GAAG,OAAO;CACf,MAAM,IAAI,WAAW,EAAE,EA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