Skip to content

Instantly share code, notes, and snippets.

@aatifbandey
Created June 24, 2021 16:25
Show Gist options
  • Save aatifbandey/41dfb0b1a04d5be142e1b8b4c535f03c to your computer and use it in GitHub Desktop.
Save aatifbandey/41dfb0b1a04d5be142e1b8b4c535f03c to your computer and use it in GitHub Desktop.
var init = function(){
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
const PROTO_PATH = __dirname +'/salary.proto';
const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
});
let employee_proto = grpc.loadPackageDefinition(packageDefinition).employee;
let { paySalary } = require('./pay_salary.js');
function main() {
let server = new grpc.Server();
server.bindAsync('0.0.0.0:4500', grpc.ServerCredentials.createInsecure(),()=>{
server.start();
});
server.addService(employee_proto.Employee.service, { paySalary: paySalary });
}
main();
}
exports.init = init;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment