Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
server.addService(bookstore_proto.Bookstore.service, {
ListShelves: testDecorator(listShelves),
CreateShelf: testDecorator(createShelf),
GetShelf: testDecorator(getShelf),
DeleteShelf: testDecorator(deleteShelf),
ListBooks: testDecorator(listBooks),
CreateBook: testDecorator(createBook),
GetBook: testDecorator(getBook),
DeleteBook: testDecorator(deleteBook),
});
// Health service following standard protocol
const statusMap = {
"": proto.grpc.health.v1.HealthCheckResponse.ServingStatus.SERVING,
};
let healthImpl = new health.Implementation(statusMap);
server.addService(health.service, healthImpl);
if (process.argv.length >= 3) {
PORT = parseInt(process.argv[2], 10);
if (isNaN(PORT) || PORT < 1024 || PORT > 65535) {
console.log(`port ${process.argv[2]} should be integer between 1024-65535`);
process.exit(1);
}
}
console.log(`GRPC Bookstore server binding to port ${PORT}`);
server.bindAsync(`0.0.0.0:${PORT}`, grpc.ServerCredentials.createInsecure(), function (error, actualPort) {
if (error) {
console.log(error);
return;
}
ListShelves: testDecorator(listShelves),
CreateShelf: testDecorator(createShelf),
GetShelf: testDecorator(getShelf),
DeleteShelf: testDecorator(deleteShelf),
ListBooks: testDecorator(listBooks),
CreateBook: testDecorator(createBook),
GetBook: testDecorator(getBook),
DeleteBook: testDecorator(deleteBook),
});
// Health service following standard protocol
const statusMap = {
"": proto.grpc.health.v1.HealthCheckResponse.ServingStatus.SERVING,
};
let healthImpl = new health.Implementation(statusMap);
server.addService(health.service, healthImpl);
if (process.argv.length >= 3) {
PORT = parseInt(process.argv[2], 10);
if (isNaN(PORT) || PORT < 1024 || PORT > 65535) {
console.log(`port ${process.argv[2]} should be integer between 1024-65535`);
process.exit(1);
}
}
console.log(`GRPC Bookstore server binding to port ${PORT}`);
server.bindAsync(`0.0.0.0:${PORT}`, grpc.ServerCredentials.createInsecure(), function (error, actualPort) {
if (error) {
console.log(error);
return;
}
if (actualPort !== PORT) {