Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let [host, port] = ['127.0.0.1', '8989']
if (window && window.location && window.location.href) {
const url = new URL(window && window.location ? window.location.href : '')
host =
url.searchParams.get('daemon-host') ||
url.searchParams.get('host') ||
'127.0.0.1'
port =
url.searchParams.get('daemon-port') ||
url.searchParams.get('port') ||
'8989'
}
export const DefautlHostname = `http://${host}:${port}`
const { MethodInfo } = grpc.AbstractClientBase
const lazyMethod = payload => payload
const unary = (client, hostname) => async (method, request, metadata) => {
const url = `${hostname}/${getServiceName(method)}/${method.name}`
// const url = `${hostname}`
const methodInfo = new MethodInfo(
method.resolvedResponseType,
lazyMethod,
lazyMethod
)
const unary = client.unaryCall(url, request, metadata || {}, methodInfo)
return unary
}
const stream = (client, hostname) => async (method, request, metadata) => {
const url = `${hostname}/${getServiceName(method)}/${method.name}`
const res = await getApplicationCount().catch((e: { code: number }) => {
// NOT_FOUND is the initial normal state, so it is excluded from error handling.
if (e.code !== StatusCode.NOT_FOUND) {
throw e;
}
});
srv.on("status", function(status: grpcWeb.Status) {
if (status.code != grpcWeb.StatusCode.OK) {
console.log("Got streaming error");
console.log("Error:", status.details);
console.log("Code:", status.code);
console.log("Metadata:", status.metadata);
}
});
}
options_: null | { [index: string]: string; };
constructor (hostname: string,
credentials?: null | { [index: string]: string; },
options?: null | { [index: string]: string; }) {
if (!options) options = {};
if (!credentials) credentials = {};
options['format'] = 'text';
this.client_ = new grpcWeb.GrpcWebClientBase(options);
this.hostname_ = hostname;
this.credentials_ = credentials;
this.options_ = options;
}
methodInfoEcho = new grpcWeb.AbstractClientBase.MethodInfo(
EchoResponse,
(request: EchoRequest) => {
return request.serializeBinary();
},
EchoResponse.deserializeBinary
);
echo(
request: EchoRequest,
metadata: grpcWeb.Metadata | null,
callback: (err: grpcWeb.Error,
response: EchoResponse) => void) {
return this.client_.rpcCall(
this.hostname_ +
'/grpc.gateway.testing.EchoService/Echo',
request,
options_: null | { [index: string]: string; };
constructor (hostname: string,
credentials?: null | { [index: string]: string; },
options?: null | { [index: string]: string; }) {
if (!options) options = {};
if (!credentials) credentials = {};
options['format'] = 'binary';
this.client_ = new grpcWeb.GrpcWebClientBase(options);
this.hostname_ = hostname;
this.credentials_ = credentials;
this.options_ = options;
}
methodInfoEcho = new grpcWeb.AbstractClientBase.MethodInfo(
EchoResponse,
(request: EchoRequest) => {
return request.serializeBinary();
},
EchoResponse.deserializeBinary
);
echo(
request: EchoRequest,
metadata: grpcWeb.Metadata | null,
callback: (err: grpcWeb.Error,
response: EchoResponse) => void) {
return this.client_.rpcCall(
this.hostname_ +
'/grpc.gateway.testing.EchoService/Echo',
request,
noOp(
request: Empty,
metadata: grpcWeb.Metadata | null,
callback: (err: grpcWeb.Error,
response: Empty) => void) {
return this.client_.rpcCall(
this.hostname_ +
'/grpc.gateway.testing.EchoService/NoOp',
request,
metadata || {},
this.methodInfoNoOp,
callback);
}
methodInfoServerStreamingEcho = new grpcWeb.AbstractClientBase.MethodInfo(
ServerStreamingEchoResponse,
(request: ServerStreamingEchoRequest) => {
return request.serializeBinary();
},
ServerStreamingEchoResponse.deserializeBinary
);
serverStreamingEcho(
request: ServerStreamingEchoRequest,
metadata?: grpcWeb.Metadata) {
return this.client_.serverStreaming(
this.hostname_ +
'/grpc.gateway.testing.EchoService/ServerStreamingEcho',
request,
metadata || {},
this.methodInfoServerStreamingEcho);
echoAbort(
request: EchoRequest,
metadata: grpcWeb.Metadata | null,
callback: (err: grpcWeb.Error,
response: EchoResponse) => void) {
return this.client_.rpcCall(
this.hostname_ +
'/grpc.gateway.testing.EchoService/EchoAbort',
request,
metadata || {},
this.methodInfoEchoAbort,
callback);
}
methodInfoNoOp = new grpcWeb.AbstractClientBase.MethodInfo(
Empty,
(request: Empty) => {
return request.serializeBinary();
},
Empty.deserializeBinary
);
noOp(
request: Empty,
metadata: grpcWeb.Metadata | null,
callback: (err: grpcWeb.Error,
response: Empty) => void) {
return this.client_.rpcCall(
this.hostname_ +
'/grpc.gateway.testing.EchoService/NoOp',
request,
constructor (hostname: string,
credentials?: null | { [index: string]: string; },
options?: null | { [index: string]: string; }) {
if (!options) options = {};
if (!credentials) credentials = {};
options['format'] = 'binary';
this.client_ = new grpcWeb.GrpcWebClientBase(options);
this.hostname_ = hostname;
this.credentials_ = credentials;
this.options_ = options;
}
constructor (hostname: string,
credentials?: null | { [index: string]: string; },
options?: null | { [index: string]: string; }) {
if (!options) options = {};
if (!credentials) credentials = {};
options['format'] = 'text';
this.client_ = new grpcWeb.GrpcWebClientBase(options);
this.hostname_ = hostname;
this.credentials_ = credentials;
this.options_ = options;
}
updateFill(
request: UpdateFillArgs,
metadata: grpcWeb.Metadata | null,
callback: (err: grpcWeb.Error,
response: UpdateFillResponse) => void) {
return this.client_.rpcCall(
this.hostname_ +
'/crossme.CrossMe/UpdateFill',
request,
metadata || {},
this.methodInfoUpdateFill,
callback);
}
methodInfoSubscribe = new grpcWeb.AbstractClientBase.MethodInfo(
SubscribeEvent,
(request: SubscribeArgs) => {
return request.serializeBinary();
},
SubscribeEvent.deserializeBinary
);
subscribe(
request: SubscribeArgs,
metadata?: grpcWeb.Metadata) {
return this.client_.serverStreaming(
this.hostname_ +
'/crossme.CrossMe/Subscribe',
request,
metadata || {},
this.methodInfoSubscribe);