Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grpc-getting-started

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc-getting-started - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

2

package.json

@@ -5,3 +5,3 @@ {

"name": "grpc-getting-started",
"version": "0.2.0",
"version": "0.3.0",
"main": "none",

@@ -8,0 +8,0 @@ "description": "Demonstration of the use of gRPC and front-end",

@@ -18,3 +18,3 @@ import { PostList, Post, FilterId } from '../proto/post_pb.js';

} else {
resolve(response.getItemsList());
resolve(response.getItemsListList());
}

@@ -30,2 +30,4 @@ });

streamReq.setTitle(`New Post Title ${Math.floor(Math.random() * 100)}`);
streamReq.setCatName('newtype');
streamReq.setLogName('newlog');

@@ -55,4 +57,4 @@ return new Promise((resolve, reject) => {

stream.on('data', (res) => {
console.log('stream.on("data") res 1: ', res.getItemsList());
data = res.getItemsList();
console.log('stream.on("data") res 1: ', res.getItemsListList());
data = res.getItemsListList();
});

@@ -119,3 +121,3 @@ stream.on('end', (res) => {

data.forEach((item) => {
res += `<li>(${item.postId}) ${item.postTitle}</li>`;
res += `<li>(${item.postId}) ${item.postTitle} - <code>${item.postCat} - ${item.postLog}</code></li>`;
});

@@ -125,3 +127,3 @@ document.getElementById('poststatus').innerHTML = `<ul>${res}</ul>`;

// display response

@@ -131,2 +133,3 @@ //===================

const data = await this.todoList();
//

@@ -138,4 +141,6 @@ const res = [];

'postId': item.getId(),
'postTitle': item.getTitle()
}
'postTitle': item.getTitle(),
'postCat': item.getCatName(),
'postLog': item.hasLogName() ? item.getLogName() : 0
}
);

@@ -159,3 +164,5 @@ });

'postId': item.getId(),
'postTitle': item.getTitle()
'postTitle': item.getTitle(),
'postCat': item.getCatName(),
'postLog': item.hasLogName() ? item.getLogName() : 0
}

@@ -162,0 +169,0 @@ );

@@ -14,2 +14,10 @@ // package: mypost

getCatName(): string;
setCatName(value: string): void;
hasLogName(): boolean;
clearLogName(): void;
getLogName(): string;
setLogName(value: string): void;
serializeBinary(): Uint8Array;

@@ -29,2 +37,4 @@ toObject(includeInstance?: boolean): Post.AsObject;

title: string,
catName: string,
logName: string,
}

@@ -34,6 +44,6 @@ }

export class PostList extends jspb.Message {
clearItemsList(): void;
getItemsList(): Array<Post>;
setItemsList(value: Array<Post>): void;
addItems(value?: Post, index?: number): Post;
clearItemsListList(): void;
getItemsListList(): Array<Post>;
setItemsListList(value: Array<Post>): void;
addItemsList(value?: Post, index?: number): Post;

@@ -52,3 +62,3 @@ serializeBinary(): Uint8Array;

export type AsObject = {
itemsList: Array<Post.AsObject>,
itemsListList: Array<Post.AsObject>,
}

@@ -55,0 +65,0 @@ }

@@ -125,3 +125,5 @@ // source: post.proto

id: jspb.Message.getFieldWithDefault(msg, 1, 0),
title: jspb.Message.getFieldWithDefault(msg, 2, "")
title: jspb.Message.getFieldWithDefault(msg, 2, ""),
catName: jspb.Message.getFieldWithDefault(msg, 3, ""),
logName: jspb.Message.getFieldWithDefault(msg, 4, "")
};

@@ -171,2 +173,10 @@

break;
case 3:
var value = /** @type {string} */ (reader.readString());
msg.setCatName(value);
break;
case 4:
var value = /** @type {string} */ (reader.readString());
msg.setLogName(value);
break;
default:

@@ -215,2 +225,16 @@ reader.skipField();

}
f = message.getCatName();
if (f.length > 0) {
writer.writeString(
3,
f
);
}
f = /** @type {string} */ (jspb.Message.getField(message, 4));
if (f != null) {
writer.writeString(
4,
f
);
}
};

@@ -255,4 +279,58 @@

/**
* optional string cat_name = 3;
* @return {string}
*/
proto.mypost.Post.prototype.getCatName = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
};
/**
* @param {string} value
* @return {!proto.mypost.Post} returns this
*/
proto.mypost.Post.prototype.setCatName = function(value) {
return jspb.Message.setProto3StringField(this, 3, value);
};
/**
* optional string log_name = 4;
* @return {string}
*/
proto.mypost.Post.prototype.getLogName = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, ""));
};
/**
* @param {string} value
* @return {!proto.mypost.Post} returns this
*/
proto.mypost.Post.prototype.setLogName = function(value) {
return jspb.Message.setField(this, 4, value);
};
/**
* Clears the field making it undefined.
* @return {!proto.mypost.Post} returns this
*/
proto.mypost.Post.prototype.clearLogName = function() {
return jspb.Message.setField(this, 4, undefined);
};
/**
* Returns whether this field is set.
* @return {boolean}
*/
proto.mypost.Post.prototype.hasLogName = function() {
return jspb.Message.getField(this, 4) != null;
};
/**
* List of repeated fields within this message type.

@@ -295,3 +373,3 @@ * @private {!Array<number>}

var f, obj = {
itemsList: jspb.Message.toObjectList(msg.getItemsList(),
itemsListList: jspb.Message.toObjectList(msg.getItemsListList(),
proto.mypost.Post.toObject, includeInstance)

@@ -337,3 +415,3 @@ };

reader.readMessage(value,proto.mypost.Post.deserializeBinaryFromReader);
msg.addItems(value);
msg.addItemsList(value);
break;

@@ -369,3 +447,3 @@ default:

var f = undefined;
f = message.getItemsList();
f = message.getItemsListList();
if (f.length > 0) {

@@ -382,6 +460,6 @@ writer.writeRepeatedMessage(

/**
* repeated Post items = 1;
* repeated Post items_list = 1;
* @return {!Array<!proto.mypost.Post>}
*/
proto.mypost.PostList.prototype.getItemsList = function() {
proto.mypost.PostList.prototype.getItemsListList = function() {
return /** @type{!Array<!proto.mypost.Post>} */ (

@@ -396,3 +474,3 @@ jspb.Message.getRepeatedWrapperField(this, proto.mypost.Post, 1));

*/
proto.mypost.PostList.prototype.setItemsList = function(value) {
proto.mypost.PostList.prototype.setItemsListList = function(value) {
return jspb.Message.setRepeatedWrapperField(this, 1, value);

@@ -407,3 +485,3 @@ };

*/
proto.mypost.PostList.prototype.addItems = function(opt_value, opt_index) {
proto.mypost.PostList.prototype.addItemsList = function(opt_value, opt_index) {
return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.mypost.Post, opt_index);

@@ -417,4 +495,4 @@ };

*/
proto.mypost.PostList.prototype.clearItemsList = function() {
return this.setItemsList([]);
proto.mypost.PostList.prototype.clearItemsListList = function() {
return this.setItemsListList([]);
};

@@ -421,0 +499,0 @@

const postsData = [
{
id: 1,
title: 'Post Title 1'
'id': 1,
'title': 'Post Title 1',
'cat_name': 'design',
'log_name': 'log1'
},
{
id: 2,
title: 'Post Title 2'
'id': 2,
'title': 'Post Title 2',
'cat_name': 'web'
},
{
id: 3,
title: 'Post Title 3'
'id': 3,
'title': 'Post Title 3',
'cat_name': 'web'
}

@@ -14,0 +18,0 @@ ];

@@ -10,3 +10,3 @@

const sendinfoProto = grpc.loadPackageDefinition(protoLoader.loadSync(PROTO_PATH_SENDINFO, {
const loadConfig = {
keepCase: true,

@@ -17,11 +17,7 @@ longs: String,

oneofs: true,
}));
const postProto = grpc.loadPackageDefinition(protoLoader.loadSync(PROTO_PATH_POST, {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
}));
};
const sendinfoProto = grpc.loadPackageDefinition(protoLoader.loadSync(PROTO_PATH_SENDINFO, loadConfig));
const postProto = grpc.loadPackageDefinition(protoLoader.loadSync(PROTO_PATH_POST, loadConfig));
/* postProto:

@@ -95,3 +91,3 @@

callback(null, {
items: postsData
items_list: postsData
});

@@ -102,3 +98,3 @@ }

call.on('data', (item) => {
postsData.push(item); // { id: xxx, title: 'New Post Title xxx' }
postsData.push(item); // { id: xxx, title: 'New Post Title xxx' , catName: 'newtype' }
});

@@ -112,3 +108,3 @@ call.on('end', () => callback(null, new Empty()));

call.write({
items: res
items_list: res
});

@@ -115,0 +111,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc