Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import path from 'path'
import * as grpc from 'grpc'
import * as protoLoader from '@grpc/proto-loader'
const proto = protoLoader.loadSync(path.resolve(__dirname, '../../_proto/post.proto'), {
enums: String,
objects: true,
arrays: true
})
const PostServiceClient = grpc.loadPackageDefinition(proto).post.PostService
export default PostServiceClient
ipcMain.on('unlockInit', async event => {
credentials = await getCredentials(lndSettingsDir);
protoPath = path.join(__dirname, '..', 'assets', 'rpc.proto');
const options = {
keepCase: false,
longs: Number,
enums: String,
defaults: true,
oneofs: true,
};
const packageDef = protoLoader.loadSync(protoPath, options);
lnrpc = grpc.loadPackageDefinition(packageDef).lnrpc;
unlocker = new lnrpc.WalletUnlocker(`localhost:${lndPort}`, credentials);
grpc.waitForClientReady(unlocker, Infinity, err => {
event.sender.send('unlockReady', { err });
});
});
function createClient() {
const packageDefinition = loadSync('modules/grpc-engine/grpc-engine.proto', {});
const grpcEngineProto = loadPackageDefinition(packageDefinition).grpcengine;
const client = new grpcEngineProto.SSR('localhost:9090', credentials.createInsecure());
return client;
}
const chalk = require('chalk')
const PROTO_PATH = __dirname + '/../service.proto'
const Photon = require('@generated/photon')
const photon = new Photon()
const grpc = require('grpc')
const protoLoader = require('@grpc/proto-loader')
const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
})
const { blog } = grpc.loadPackageDefinition(packageDefinition)
async function post(call, callback) {
const { id } = call.request
const post = await photon.posts.findOne({
where: {
id,
},
})
callback(null, post)
function createClient({ protoPath, packageName, serviceName, options }, address, creds=grpc.credentials.createInsecure()){
const pkgDef = grpc.loadPackageDefinition(protoLoader.loadSync(protoPath, options));
const proto = getProtoFromPackageDefinition(pkgDef, packageName);
return new proto[serviceName](address, creds);
}
}
} catch (err) {
return { code: 1, log: err.toString() };
}
}
};
const options = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const protoDefinition = protoLoader.loadSync(PROTO_PATH, options)['types.ABCIApplication'];
const server = new grpc.Server();
const services = {};
Object.keys(protoDefinition).forEach((k) => {
const method = _.lowerFirst(k);
if (app[method]) {
services[method] = (call, callback) => {
app[method](call.request).then(res => callback(null, res)).catch(callback);
};
} else {
services[method] = (_call, callback) => {
callback(null, {});
};
}
const grpc = require("grpc");
const protoLoader = require("@grpc/proto-loader");
const discovery = require('../discovery');
const logger = require('../logger');
const PROTO_PATH = './app/grpc/QueryService.proto';
let grpcClientInstance;
const queryproto = grpc.loadPackageDefinition(
protoLoader.loadSync(PROTO_PATH, {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true
})
);
const grpcClient = {
getRecords: async function (query) {
logger.info(`Get records for query ${query}`);
let client = grpcClientInstance;
logger.info(`Get records obtained client`, client);
return new Promise((resolve, reject) => {
logger.info(`Get records promise`, query);
client.GetData(query, (error, response) => {
const PROTO_PATH = __dirname + '/../service.proto'
const grpc = require('grpc')
const protoLoader = require('@grpc/proto-loader')
const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
})
const blog = grpc.loadPackageDefinition(packageDefinition).blog
function main() {
const client = new blog.Blog(
'localhost:50051',
grpc.credentials.createInsecure(),
)
client.feed({}, (err, response) => {
if (err) {