How to use the @grpc/grpc-js.ServerCredentials.createInsecure function in @grpc/grpc-js

To help you get started, we’ve selected a few @grpc/grpc-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger-labs / weaver-dlt-interoperability / core / drivers / fabric-driver / server / server.ts View on Github external
// uses the network name to create a unique wallet path
    const walletPath = path.join(process.cwd(), `wallet-${process.env.NETWORK_NAME}`);
    if (process.env.CONNECTION_PROFILE) {
        walletSetup(
            walletPath,
            process.env.CONNECTION_PROFILE,
            process.env.NETWORK_NAME ? process.env.NETWORK_NAME : 'network1',
        );
    } else {
        console.error('No CONNECTION_PROFILE provided in the .env');
    }
};

// SERVER: Start the server with the provided url.
// TODO: We should have credentials locally to ensure that the driver can only communicate with the local relay.
server.bindAsync(`${process.env.DRIVER_ENDPOINT}`, ServerCredentials.createInsecure(), (cb) => {
    configSetup().then(() => {
        server.start();
    });
});
github depscloud / depscloud / extractor / src / main.ts View on Github external
}
        });

        const impl: AsyncDependencyExtractor = new DependencyExtractorImpl(matchersAndExtractors);

        const healthcheck = new health.Implementation({
            "": healthv1.HealthCheckResponse.ServingStatus.SERVING,
        });
        // toggle the service health as such
        // healthcheck.setStatus("", healthv1.HealthCheckResponse.ServingStatus.NOT_SERVING);

        const server = new Server();
        server.addService(DependencyExtractor.service, unasyncify(impl));
        server.addService(health.service, healthcheck);

        let credentials = ServerCredentials.createInsecure();
        if (options.tlsKey && options.tlsCert && options.tlsCa) {
            const [ key, cert, ca ] = await Promise.all([
                asyncFs.readFile(options.tlsKey),
                asyncFs.readFile(options.tlsCert),
                asyncFs.readFile(options.tlsCa),
            ]);

            credentials = ServerCredentials.createSsl(ca, [ {
                private_key: key,
                cert_chain: cert,
            } ], true);
        }

        const bindAddress = options.bindAddress || "0.0.0.0";
        const httpPort = options.httpPort || 8080;
        const grpcPort = options.port || options.grpcPort || 8090;
github cjihrig / grpc-server-js / lib / server.js View on Github external
bind (port, creds) {
    if (this[kStarted] === true) {
      throw new Error('server is already started');
    }

    if (typeof port === 'number') {
      port = `localhost:${port}`;
    }

    if (creds === null || typeof creds !== 'object') {
      creds = ServerCredentials.createInsecure();
    }

    return new Promise((resolve, reject) => {
      this.bindAsync(port, creds, (err, boundPort) => {
        if (err) {
          reject(err);
        }

        resolve(boundPort);
      });
    });
  }