Skip to content

Commit

Permalink
Upgrade typescript dependency because of eslint error
Browse files Browse the repository at this point in the history
  • Loading branch information
w1am committed Nov 20, 2023
1 parent ddbe890 commit 0688727
Show file tree
Hide file tree
Showing 147 changed files with 2,469 additions and 2,202 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@
"grpc_tools_node_protoc_ts": "^5.3.2",
"jest": "^27.3.1",
"npm-run-all": "^4.1.5",
"prettier": "^3.1.0",
"prettier": "^2.4.1",
"shx": "^0.3.3",
"ts-jest": "^27.0.7",
"typescript": "^5.2.2"
"typescript": "^4.4.2"
}
}
}
6 changes: 3 additions & 3 deletions src/Client/ServerFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Status } from "@grpc/grpc-js/build/src/constants";
type ExecuteClientCapabilities = [
GRPCClientConstructor<ServerFeaturesClient>,
string,
(c: ServerFeaturesClient) => Promise<ServerFeatures>,
(c: ServerFeaturesClient) => Promise<ServerFeatures>
];

const UNKNOWN = "unknown";
Expand Down Expand Up @@ -40,7 +40,7 @@ export class ServerFeatures {
if (error) {
debug.connection(
"Failed to fetch server features with error: %s",
error.message,
error.message
);
debug.connection("Assuming unknown server version.");
return;
Expand All @@ -61,7 +61,7 @@ export class ServerFeatures {
public supports = (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
method: MethodDefinition<any, any>,
feature?: string,
feature?: string
): boolean => {
const path = method.path.toLowerCase();
const isSupported = feature
Expand Down
16 changes: 8 additions & 8 deletions src/Client/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const discoverEndpoint = async (
...settings
}: DNSClusterOptions | GossipClusterOptions,
credentials: ChannelCredentials,
failedEndpoint?: EndPoint,
failedEndpoint?: EndPoint
): Promise<EndPoint> => {
let discoverAttempts = 0;

Expand Down Expand Up @@ -56,14 +56,14 @@ export const discoverEndpoint = async (
const members = await listClusterMembers(
candidate,
credentials,
createDeadline(gossipTimeout),
createDeadline(gossipTimeout)
);
const endpoint = determineBestNode(nodePreference, members);
if (endpoint) return Promise.resolve(endpoint);
} catch (error) {
debug.connection(
`Failed to get cluster list from ${candidate.address}:${candidate.port}`,
error.toString(),
error.toString()
);
continue;
}
Expand Down Expand Up @@ -109,7 +109,7 @@ const getPreferedStates = (preference: NodePreference) => {

type CompareFn<T> = (a: T, b: T) => number;
const compareByPreference = (
preference: NodePreference,
preference: NodePreference
): CompareFn<MemberInfo> => {
const preferedStates = getPreferedStates(preference);
return (a, b) =>
Expand All @@ -119,7 +119,7 @@ const shuffle: CompareFn<unknown> = () => Math.random() - 0.5;

export const filterAndOrderMembers = (
preference: NodePreference,
members: MemberInfo[],
members: MemberInfo[]
): MemberInfo[] =>
members
.filter(isInAllowedState)
Expand All @@ -128,12 +128,12 @@ export const filterAndOrderMembers = (

export const determineBestNode = (
preference: NodePreference,
members: MemberInfo[],
members: MemberInfo[]
): EndPoint | undefined => {
debug.connection(
`Determining best node with preference "%s" from members: %O`,
preference,
members,
members
);

const [chosenMember] = filterAndOrderMembers(preference, members);
Expand All @@ -157,7 +157,7 @@ function createDeadline(seconds: number) {
function listClusterMembers(
seed: EndPoint,
credentials: ChannelCredentials,
deadline: Date,
deadline: Date
): Promise<MemberInfo[]> {
const uri = `${seed.address}:${seed.port}`;
const client = new GossipClient(uri, credentials, {});
Expand Down
24 changes: 12 additions & 12 deletions src/Client/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { ChannelCredentialOptions, Client } from "./";
type TransformError = (
statusCode: number,
statusMessage: string,
res: IncomingMessage,
res: IncomingMessage
) => Error | undefined;

export interface HTTPRequestOptions extends BaseOptions {
Expand Down Expand Up @@ -41,7 +41,7 @@ export class HTTP {
constructor(
client: Client,
channelCredentials: ChannelCredentialOptions,
defaultUserCredentials?: Credentials,
defaultUserCredentials?: Credentials
) {
this.#client = client;
this.#channelCredentials = channelCredentials;
Expand All @@ -53,7 +53,7 @@ export class HTTP {
method: HTTPMethod,
path: string,
{ searchParams, ...options }: HTTPRequestOptions,
body?: string,
body?: string
): Promise<T> => {
const url = await this.createURL(path, searchParams);
return this.makeRequest<T>(method, url, options, body);
Expand All @@ -63,7 +63,7 @@ export class HTTP {
method: HTTPMethod,
url: URL,
options: HTTPRequestOptions,
body?: string,
body?: string
) =>
new Promise<T>((resolve, reject) => {
const headers: Record<string, string> = {
Expand All @@ -74,7 +74,7 @@ export class HTTP {

if (!this.#insecure && credentials) {
headers["Authorization"] = `Basic ${Buffer.from(
`${credentials.username}:${credentials.password}`,
`${credentials.username}:${credentials.password}`
).toString("base64")}`;
}

Expand All @@ -89,8 +89,8 @@ export class HTTP {
method,
new URL(res.headers.location!, url),
options,
body,
),
body
)
);
}

Expand All @@ -99,7 +99,7 @@ export class HTTP {
options.transformError?.(
res.statusCode!,
res.statusMessage!,
res,
res
) ??
defaultTransformError(res.statusCode!, res.statusMessage!, res);

Expand All @@ -120,7 +120,7 @@ export class HTTP {
`Making %s call to %s with headers %h`,
method,
url.toString(),
headers,
headers
);

const req = this.#insecure
Expand All @@ -130,7 +130,7 @@ export class HTTP {
method,
headers,
},
callback,
callback
)
: httpsRequest(
url,
Expand All @@ -139,7 +139,7 @@ export class HTTP {
headers,
ca,
},
callback,
callback
);

req.on("error", (error) => {
Expand All @@ -155,7 +155,7 @@ export class HTTP {

private createURL = async (
pathname: string,
searchParams: Record<string, string | undefined> = {},
searchParams: Record<string, string | undefined> = {}
): Promise<URL> => {
const channel = await this.getChannel.call(this.#client);
const protocol = this.#insecure ? "http://" : "https://";
Expand Down
Loading

0 comments on commit 0688727

Please sign in to comment.