Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let grpc = require('grpc');
let proto = grpc.load(__dirname+"/../test/test.proto");
let grpcctest = proto.grpcctest;
let server = new grpc.Server();
server.addService(grpcctest.TestService.service, {
sayHello: function sayHello(call, done) {
log('sayHello()');
log('Metadata', call.metadata);
log('Request', call.request);
// Send back the same metadata we received
call.sendMetadata(call.metadata)
done(null, { saidWhat: call.request.sayWhat });
},
sayClientStream: function sayClientStream(call, done) {
log('sayClientStream()');
log('Metadata', call.metadata);
let agg = [];
var grpc = require('grpc');
var booksProto = grpc.load('books.proto');
// In-memory array of book objects
var books = [{
id: 123,
title: 'A Tale of Two Cities',
author: 'Charles Dickens'
}];
var server = new grpc.Server();
server.addProtoService(booksProto.books.BookService.service, {
list: function(call, callback) {
callback(null, books);
},
insert: function(call, callback) {
books.push(call.request);
callback(null, {});
}
});
server.bind('127.0.0.1:50051', grpc.ServerCredentials.createInsecure());
server.start();
export function getServer(): grpc.Server {
const server = new grpc.Server();
server.addService(todo_proto.ListActions.service, {
GetList: GetList,
AddItem: AddItem,
ItemStreamer: ItemStreamer,
CalculateAverage: CalculateAverage,
TestServerStream: TestServerStream,
});
return server;
}
function main() {
let server = new grpc.Server();
server.addService(BookService, {
getBook: getBook,
getBooksViaAuthor: getBooksViaAuthor,
getGreatestBook: getGreatestBook,
getBooks: getBooks
});
server.bind('127.0.0.1:50051', grpc.ServerCredentials.createInsecure());
console.log('Listening on: 127.0.0.1:50051');
server.start();
}
main();
}
async function publish(call, callback) {
const { id } = call.request
try {
const publishedPost = await prisma.updatePost({
where: { id },
data: { published: true },
})
callback(null, publishedPost)
} catch (e) {
callback(e, null)
}
}
const server = new grpc.Server()
server.addService(blog.Blog.service, {
feed,
post,
filterPosts,
signupUser,
createDraft,
publish,
deletePost,
})
server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure())
const message = `
The gRPC server is being started on ${chalk.bold(`0.0.0.0:50051`)}. You now can invoke any client script by its name, e.g.:
${chalk.bold(`$ npm run feed`)}
or
${chalk.bold(`$ npm run signupUser`)}
function getServer() {
const server = new grpc.Server();
server.addService(services.RouteGuideService, {
getFeature: getFeature,
listFeatures: listFeatures,
recordRoute: recordRoute,
routeChat: routeChat
});
return server;
}
function getServer() {
var server = new grpc.Server();
server.addService(helloworld.Greeter.service, {
sayHello: doSayHello,
sayRepeatHello: doSayRepeatHello,
sayHelloAfterDelay: doSayHelloAfterDelay
});
return server;
}
function getServer() {
var server = new grpc.Server()
server.addService(routeguide.RouteGuide.service, {
getFeature: getFeature
})
return server
}
function main() {
var server = new grpc.Server();
server.addService(services.GreeterService, { sayHello: sayHello });
server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
server.start();
}