Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow MSW to intercept connect-node client HTTP-requests #1324

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/connect-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default function (router: ConnectRouter) {

```diff
// server.ts
import * as http2 from "http2";
import http2 from "node:http2";
+ import routes from "connect";
+ import { connectNodeAdapter } from "@connectrpc/connect-node";

Expand Down
6 changes: 3 additions & 3 deletions packages/connect-node/conformance/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import {
compressionGzip,
connectNodeAdapter,
} from "../src/index.js";
import * as http from "node:http";
import * as http2 from "node:http2";
import * as https from "node:https";
import http from "node:http";
import http2 from "node:http2";
import https from "node:https";
import * as net from "node:net";
import { createRegistry } from "@bufbuild/protobuf";
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-node/conformance/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
createGrpcWebTransport,
} from "../src/index.js";
import type { Compression } from "@connectrpc/connect/protocol";
import * as http2 from "node:http2";
import http2 from "node:http2";

/**
* Configure a transport for a client from @connectrpc/connect-node under test.
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-node/src/http2-session-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import { useNodeServer } from "./use-node-server-helper.spec.js";
import * as http2 from "http2";
import http2 from "node:http2";
import { Http2SessionManager } from "./http2-session-manager.js";
import { ConnectError } from "@connectrpc/connect";
import { Worker } from "worker_threads";
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-node/src/http2-session-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import * as http2 from "http2";
import http2 from "node:http2";
import { Code, ConnectError } from "@connectrpc/connect";
import { connectErrorFromNodeReason } from "./node-error.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/connect-node/src/node-readme.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import * as http2 from "http2";
import http2 from "node:http2";
import { Message, MethodKind, proto3 } from "@bufbuild/protobuf";
import type { PartialMessage } from "@bufbuild/protobuf";
import {
Expand Down
6 changes: 3 additions & 3 deletions packages/connect-node/src/node-transport-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import { createNodeHttpClient } from "./node-universal-client.js";
import type { NodeHttp2ClientSessionManager } from "./node-universal-client.js";
import { Http2SessionManager } from "./http2-session-manager.js";
import type { Http2SessionOptions } from "./http2-session-manager.js";
import * as http2 from "http2";
import * as http from "http";
import * as https from "https";
import http2 from "node:http2";
import http from "node:http";
import https from "node:https";

/**
* Options specific to Node.js client transports.
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-node/src/node-universal-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import * as http2 from "http2";
import * as http from "http";
import http2 from "node:http2";
import http from "node:http";
import { ConnectError } from "@connectrpc/connect";
import { createAsyncIterable } from "@connectrpc/connect/protocol";
import { createNodeHttpClient } from "./node-universal-client.js";
Expand Down
6 changes: 3 additions & 3 deletions packages/connect-node/src/node-universal-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import * as http2 from "http2";
import * as http from "http";
import * as https from "https";
import http2 from "node:http2";
import http from "node:http";
import https from "node:https";
import type * as net from "net";
import { Code, ConnectError } from "@connectrpc/connect";
import {
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-node/src/node-universal-handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.

import { useNodeServer } from "./use-node-server-helper.spec.js";
import * as http2 from "http2";
import * as http from "http";
import http2 from "node:http2";
import http from "node:http";
import { universalRequestFromNodeRequest } from "./node-universal-handler.js";
import { ConnectError } from "@connectrpc/connect";
import { getNodeErrorProps } from "./node-error.js";
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-node/src/node-universal-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import type * as http from "http";
import type * as http2 from "http2";
import type * as http from "node:http";
import type * as http2 from "node:http2";
import type * as stream from "stream";
import type { JsonValue } from "@bufbuild/protobuf";
import { Code, ConnectError } from "@connectrpc/connect";
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-node/src/node-universal-header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import * as http from "http";
import http from "node:http";
import {
nodeHeaderToWebHeader,
webHeaderToNodeHeaders,
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-node/src/node-universal-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import type * as http from "http";
import type * as http2 from "http2";
import type * as http from "node:http";
import type * as http2 from "node:http2";

/**
* Convert a Node.js header object to a fetch API Headers object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-floating-promises */

import { Http2SessionManager } from "../http2-session-manager.js";
import * as http2 from "http2";
import http2 from "node:http2";
import { parentPort, workerData } from "worker_threads";

const sm = new Http2SessionManager(workerData, {
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-node/src/transport.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/* eslint-disable @typescript-eslint/no-invalid-void-type */
import { Int32Value, StringValue, MethodKind } from "@bufbuild/protobuf";
import { useNodeServer } from "./use-node-server-helper.spec.js";
import * as http2 from "node:http2";
import http2 from "node:http2";
import { connectNodeAdapter } from "./connect-node-adapter.js";
import { createClient } from "@connectrpc/connect";
import type { Transport } from "@connectrpc/connect";
Expand Down
6 changes: 3 additions & 3 deletions packages/connect-node/src/use-node-server-helper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import * as http2 from "http2";
import * as http from "http";
import * as https from "https";
import http2 from "node:http2";
import http from "node:http";
import https from "node:https";
import type { UniversalClientFn } from "@connectrpc/connect/protocol";
import { Http2SessionManager } from "./http2-session-manager.js";
import { createNodeHttpClient } from "./node-universal-client.js";
Expand Down