-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from sondt-1245/feat/views_count_service
feat: send grpc request to check post viewed
- Loading branch information
Showing
16 changed files
with
2,595 additions
and
31 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
PROTO_DIR=./proto | ||
|
||
# Generate JavaScript code | ||
yarn run grpc_tools_node_protoc \ | ||
--js_out=import_style=commonjs,binary:${PROTO_DIR} \ | ||
--grpc_out=${PROTO_DIR} \ | ||
--plugin=protoc-gen-grpc=./node_modules/.bin/grpc_tools_node_protoc_plugin \ | ||
-I ./proto \ | ||
proto/*.proto | ||
|
||
# Generate TypeScript code (d.ts) | ||
yarn run grpc_tools_node_protoc \ | ||
--plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \ | ||
--ts_out=${PROTO_DIR} \ | ||
-I ./proto \ | ||
proto/*.proto |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
syntax = "proto3"; | ||
|
||
package views_count; | ||
|
||
message IncrementStoryViewRequest { | ||
string hashid = 1; | ||
string fingerprint = 2; | ||
} | ||
|
||
message Empty {}; | ||
|
||
message StatusResponse { | ||
bool success = 1; | ||
} | ||
|
||
service ViewsCount { | ||
rpc IncrementStoryView(IncrementStoryViewRequest) returns (StatusResponse); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// package: views_count | ||
// file: views_count.proto | ||
|
||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
import * as grpc from "grpc"; | ||
import * as views_count_pb from "./views_count_pb"; | ||
|
||
interface IViewsCountService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> { | ||
incrementStoryView: IViewsCountService_IIncrementStoryView; | ||
} | ||
|
||
interface IViewsCountService_IIncrementStoryView extends grpc.MethodDefinition<views_count_pb.IncrementStoryViewRequest, views_count_pb.StatusResponse> { | ||
path: "/views_count.ViewsCount/IncrementStoryView"; | ||
requestStream: false; | ||
responseStream: false; | ||
requestSerialize: grpc.serialize<views_count_pb.IncrementStoryViewRequest>; | ||
requestDeserialize: grpc.deserialize<views_count_pb.IncrementStoryViewRequest>; | ||
responseSerialize: grpc.serialize<views_count_pb.StatusResponse>; | ||
responseDeserialize: grpc.deserialize<views_count_pb.StatusResponse>; | ||
} | ||
|
||
export const ViewsCountService: IViewsCountService; | ||
|
||
export interface IViewsCountServer { | ||
incrementStoryView: grpc.handleUnaryCall<views_count_pb.IncrementStoryViewRequest, views_count_pb.StatusResponse>; | ||
} | ||
|
||
export interface IViewsCountClient { | ||
incrementStoryView(request: views_count_pb.IncrementStoryViewRequest, callback: (error: grpc.ServiceError | null, response: views_count_pb.StatusResponse) => void): grpc.ClientUnaryCall; | ||
incrementStoryView(request: views_count_pb.IncrementStoryViewRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: views_count_pb.StatusResponse) => void): grpc.ClientUnaryCall; | ||
incrementStoryView(request: views_count_pb.IncrementStoryViewRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: views_count_pb.StatusResponse) => void): grpc.ClientUnaryCall; | ||
} | ||
|
||
export class ViewsCountClient extends grpc.Client implements IViewsCountClient { | ||
constructor(address: string, credentials: grpc.ChannelCredentials, options?: object); | ||
public incrementStoryView(request: views_count_pb.IncrementStoryViewRequest, callback: (error: grpc.ServiceError | null, response: views_count_pb.StatusResponse) => void): grpc.ClientUnaryCall; | ||
public incrementStoryView(request: views_count_pb.IncrementStoryViewRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: views_count_pb.StatusResponse) => void): grpc.ClientUnaryCall; | ||
public incrementStoryView(request: views_count_pb.IncrementStoryViewRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: views_count_pb.StatusResponse) => void): grpc.ClientUnaryCall; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// GENERATED CODE -- DO NOT EDIT! | ||
|
||
'use strict'; | ||
var grpc = require('grpc'); | ||
var views_count_pb = require('./views_count_pb.js'); | ||
|
||
function serialize_views_count_IncrementStoryViewRequest(arg) { | ||
if (!(arg instanceof views_count_pb.IncrementStoryViewRequest)) { | ||
throw new Error('Expected argument of type views_count.IncrementStoryViewRequest'); | ||
} | ||
return Buffer.from(arg.serializeBinary()); | ||
} | ||
|
||
function deserialize_views_count_IncrementStoryViewRequest(buffer_arg) { | ||
return views_count_pb.IncrementStoryViewRequest.deserializeBinary(new Uint8Array(buffer_arg)); | ||
} | ||
|
||
function serialize_views_count_StatusResponse(arg) { | ||
if (!(arg instanceof views_count_pb.StatusResponse)) { | ||
throw new Error('Expected argument of type views_count.StatusResponse'); | ||
} | ||
return Buffer.from(arg.serializeBinary()); | ||
} | ||
|
||
function deserialize_views_count_StatusResponse(buffer_arg) { | ||
return views_count_pb.StatusResponse.deserializeBinary(new Uint8Array(buffer_arg)); | ||
} | ||
|
||
|
||
var ViewsCountService = exports.ViewsCountService = { | ||
incrementStoryView: { | ||
path: '/views_count.ViewsCount/IncrementStoryView', | ||
requestStream: false, | ||
responseStream: false, | ||
requestType: views_count_pb.IncrementStoryViewRequest, | ||
responseType: views_count_pb.StatusResponse, | ||
requestSerialize: serialize_views_count_IncrementStoryViewRequest, | ||
requestDeserialize: deserialize_views_count_IncrementStoryViewRequest, | ||
responseSerialize: serialize_views_count_StatusResponse, | ||
responseDeserialize: deserialize_views_count_StatusResponse, | ||
}, | ||
}; | ||
|
||
exports.ViewsCountClient = grpc.makeGenericClientConstructor(ViewsCountService); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// package: views_count | ||
// file: views_count.proto | ||
|
||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
import * as jspb from "google-protobuf"; | ||
|
||
export class IncrementStoryViewRequest extends jspb.Message { | ||
getHashid(): string; | ||
setHashid(value: string): IncrementStoryViewRequest; | ||
|
||
getFingerprint(): string; | ||
setFingerprint(value: string): IncrementStoryViewRequest; | ||
|
||
|
||
serializeBinary(): Uint8Array; | ||
toObject(includeInstance?: boolean): IncrementStoryViewRequest.AsObject; | ||
static toObject(includeInstance: boolean, msg: IncrementStoryViewRequest): IncrementStoryViewRequest.AsObject; | ||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>}; | ||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>}; | ||
static serializeBinaryToWriter(message: IncrementStoryViewRequest, writer: jspb.BinaryWriter): void; | ||
static deserializeBinary(bytes: Uint8Array): IncrementStoryViewRequest; | ||
static deserializeBinaryFromReader(message: IncrementStoryViewRequest, reader: jspb.BinaryReader): IncrementStoryViewRequest; | ||
} | ||
|
||
export namespace IncrementStoryViewRequest { | ||
export type AsObject = { | ||
hashid: string, | ||
fingerprint: string, | ||
} | ||
} | ||
|
||
export class Empty extends jspb.Message { | ||
|
||
serializeBinary(): Uint8Array; | ||
toObject(includeInstance?: boolean): Empty.AsObject; | ||
static toObject(includeInstance: boolean, msg: Empty): Empty.AsObject; | ||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>}; | ||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>}; | ||
static serializeBinaryToWriter(message: Empty, writer: jspb.BinaryWriter): void; | ||
static deserializeBinary(bytes: Uint8Array): Empty; | ||
static deserializeBinaryFromReader(message: Empty, reader: jspb.BinaryReader): Empty; | ||
} | ||
|
||
export namespace Empty { | ||
export type AsObject = { | ||
} | ||
} | ||
|
||
export class StatusResponse extends jspb.Message { | ||
getSuccess(): boolean; | ||
setSuccess(value: boolean): StatusResponse; | ||
|
||
|
||
serializeBinary(): Uint8Array; | ||
toObject(includeInstance?: boolean): StatusResponse.AsObject; | ||
static toObject(includeInstance: boolean, msg: StatusResponse): StatusResponse.AsObject; | ||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>}; | ||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>}; | ||
static serializeBinaryToWriter(message: StatusResponse, writer: jspb.BinaryWriter): void; | ||
static deserializeBinary(bytes: Uint8Array): StatusResponse; | ||
static deserializeBinaryFromReader(message: StatusResponse, reader: jspb.BinaryReader): StatusResponse; | ||
} | ||
|
||
export namespace StatusResponse { | ||
export type AsObject = { | ||
success: boolean, | ||
} | ||
} |
Oops, something went wrong.