Initial commit

This commit is contained in:
Ace Nassri 2018-06-22 13:43:39 -07:00
parent a1b141d5b3
commit 28a6fbb8f1
9 changed files with 1260 additions and 0 deletions

View file

@ -0,0 +1,47 @@
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
const path = require('path');
const grpc = require('grpc');
const PROTO_PATH = path.join(__dirname, './proto/currency_service.proto');
const PORT = 31337;
const shopProto = grpc.load(PROTO_PATH).hipstershop;
const client = new shopProto.CurrencyService(`localhost:${PORT}`,
grpc.credentials.createInsecure());
const request = {
from: {
currency_code: 'USD',
amount: {
decimal: 300,
fractional: 0
}
},
to_code: 'CHF'
};
client.convert(request, function (err, response) {
if (err) {
console.error(err);
} else {
const amount = response.amount;
console.log(`OUTPUT: ${amount.decimal}.${amount.fractional}`);
}
});