Created
June 24, 2021 16:25
-
-
Save aatifbandey/41dfb0b1a04d5be142e1b8b4c535f03c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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