├── docker ├── nginx │ ├── logs │ │ └── .gitkeep │ ├── config │ │ ├── server.template.conf │ │ └── nginx.conf │ ├── Dockerfile │ └── entrypoint.sh ├── python │ ├── entrypoint-server.sh │ └── Dockerfile ├── nodejs │ ├── entrypoint-microservices.sh │ ├── Dockerfile │ └── entrypoint-server.sh └── go │ ├── entrypoint-server.sh │ └── Dockerfile ├── app-products ├── src │ ├── proto │ │ ├── __init__.py │ │ └── products │ │ │ ├── __init__.py │ │ │ ├── products.proto │ │ │ ├── products_pb2_grpc.py │ │ │ └── products_pb2.py │ ├── __init__.py │ ├── controllers │ │ ├── __init__.py │ │ └── ProductsController.py │ └── server.py └── scripts │ └── protoc.sh ├── app-gateway ├── src │ ├── Index.ts │ ├── config │ │ └── grpc │ │ │ ├── ILoadClientGRPC.ts │ │ │ ├── proto │ │ │ ├── products.proto │ │ │ ├── customers.proto │ │ │ ├── orders.proto │ │ │ └── users.proto │ │ │ └── LoadClientGRPC.ts │ ├── api │ │ ├── orders │ │ │ ├── OrdersRouter.ts │ │ │ ├── OrdersService.ts │ │ │ └── OrdersController.ts │ │ ├── products │ │ │ ├── ProductsRouter.ts │ │ │ ├── ProductsService.ts │ │ │ └── ProductsController.ts │ │ ├── customers │ │ │ ├── CustomersRouter.ts │ │ │ ├── CustomersService.ts │ │ │ └── CustomersController.ts │ │ ├── users │ │ │ ├── UsersRouter.ts │ │ │ ├── UsersService.ts │ │ │ └── UsersController.ts │ │ └── IndexRouter.ts │ ├── App.ts │ └── ConnectServer.ts ├── tsconfig.json ├── ecosystem.config.js ├── package.json └── tslint.json ├── architecture.png ├── editor-preview.gif ├── app-users ├── src │ ├── proto │ │ ├── index.ts │ │ └── users │ │ │ ├── users.proto │ │ │ ├── users_grpc_pb.js │ │ │ ├── users_pb.d.ts │ │ │ └── users_grpc_pb.d.ts │ ├── server.ts │ ├── repositories │ │ └── UsersRepository.ts │ └── controllers │ │ └── UsersController.ts ├── tsconfig.json ├── scripts │ └── protoc.sh └── package.json ├── app-customers ├── src │ ├── proto │ │ ├── index.ts │ │ └── customers │ │ │ ├── customers.proto │ │ │ ├── customers_grpc_pb.js │ │ │ ├── customers_pb.d.ts │ │ │ ├── customers_grpc_pb.d.ts │ │ │ └── customers_pb.js │ ├── server.ts │ ├── repositories │ │ └── CustomersRepository.ts │ └── controllers │ │ └── CustomersController.ts ├── tsconfig.json ├── scripts │ └── protoc.sh └── package.json ├── app-orders └── src │ ├── main.go │ ├── proto │ └── orders.proto │ └── controllers │ └── orders.controller.go ├── docker-compose.override.dist.yml ├── Makefile ├── docker-compose.yml ├── README.md └── .gitignore /docker/nginx/logs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app-products/src/proto/__init__.py: -------------------------------------------------------------------------------- 1 | from products import * -------------------------------------------------------------------------------- /app-products/src/__init__.py: -------------------------------------------------------------------------------- 1 | from proto import * 2 | from controllers import * -------------------------------------------------------------------------------- /app-products/src/controllers/__init__.py: -------------------------------------------------------------------------------- 1 | from ProductsController import ProductsController -------------------------------------------------------------------------------- /app-gateway/src/Index.ts: -------------------------------------------------------------------------------- 1 | import server from './ConnectServer'; 2 | 3 | server.startServer(); 4 | -------------------------------------------------------------------------------- /app-products/src/proto/products/__init__.py: -------------------------------------------------------------------------------- 1 | from products_pb2 import * 2 | from products_pb2_grpc import * -------------------------------------------------------------------------------- /architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemicharly/api-gateway-grpc-microservice/HEAD/architecture.png -------------------------------------------------------------------------------- /editor-preview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemicharly/api-gateway-grpc-microservice/HEAD/editor-preview.gif -------------------------------------------------------------------------------- /docker/python/entrypoint-server.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | echo "Start application server..." 4 | 5 | python $APP_HOME/src/server.py 50053 6 | 7 | exec "$@" -------------------------------------------------------------------------------- /app-users/src/proto/index.ts: -------------------------------------------------------------------------------- 1 | /*TODO: Register _grpc and _pb*/ 2 | import './users/users_pb'; 3 | import './users/users_grpc_pb' 4 | 5 | export const protoIndex: any = (): void => { 6 | }; 7 | -------------------------------------------------------------------------------- /app-customers/src/proto/index.ts: -------------------------------------------------------------------------------- 1 | /*TODO: Register _grpc and _pb*/ 2 | import './customers/customers_pb'; 3 | import './customers/customers_grpc_pb' 4 | 5 | export const protoIndex: any = (): void => { 6 | }; 7 | -------------------------------------------------------------------------------- /docker/nodejs/entrypoint-microservices.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | cd /opt/app 4 | 5 | echo "Install packaged..." 6 | yarn 7 | 8 | echo "Start development application server..." 9 | yarn dev; 10 | 11 | exec "$@" -------------------------------------------------------------------------------- /app-gateway/src/config/grpc/ILoadClientGRPC.ts: -------------------------------------------------------------------------------- 1 | import {ChannelCredentials} from 'grpc'; 2 | 3 | 4 | export interface ILoadClientGRPC { 5 | serviceName: string; 6 | fileName: string; 7 | address: string; 8 | credentials?: ChannelCredentials; 9 | } -------------------------------------------------------------------------------- /docker/go/entrypoint-server.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | cd src 4 | 5 | echo "Generate the go module with file proto" 6 | protoc -I proto/ proto/orders.proto --go_out=plugins=grpc:proto 7 | 8 | echo "Start application microservice go..." 9 | 10 | go run main.go 11 | 12 | exec "$@" -------------------------------------------------------------------------------- /docker/python/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM grpc/python 2 | 3 | RUN pip install --upgrade pip \ 4 | && pip install grpcio grpcio-tools 5 | 6 | ENV APP_HOME /opt/app 7 | 8 | WORKDIR $APP_HOME 9 | 10 | COPY docker/python/entrypoint-server.sh /usr/local/bin 11 | RUN chmod -R 777 /usr/local/bin/entrypoint-server.sh -------------------------------------------------------------------------------- /app-gateway/src/api/orders/OrdersRouter.ts: -------------------------------------------------------------------------------- 1 | import express, {Request, Response} from 'express'; 2 | import OrdersController from './OrdersController'; 3 | 4 | const router = express.Router(); 5 | 6 | router.get('/', OrdersController.findAll); 7 | router.post('/', OrdersController.create); 8 | 9 | 10 | export default router; -------------------------------------------------------------------------------- /app-products/scripts/protoc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BASEDIR=$(dirname "$0") 4 | cd "${BASEDIR}"/../ 5 | 6 | echo "Generator proto products gRPC..."; 7 | 8 | python -m grpc_tools.protoc \ 9 | --proto_path=./src/proto \ 10 | --python_out=./src/proto \ 11 | --grpc_python_out=./src/proto \ 12 | ./src/proto/products/products.proto 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app-customers/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist/", 4 | "module": "commonjs", 5 | "noImplicitAny": true, 6 | "allowJs": true, 7 | "esModuleInterop": true, 8 | "target": "es6", 9 | "sourceMap": true 10 | }, 11 | "include": [ 12 | "./src/**/*" 13 | ], 14 | "exclude": [ 15 | "../app/node_modules" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /app-users/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist/", 4 | "module": "commonjs", 5 | "noImplicitAny": true, 6 | "allowJs": true, 7 | "esModuleInterop": true, 8 | "target": "es6", 9 | "sourceMap": true 10 | }, 11 | "include": [ 12 | "./src/**/*" 13 | ], 14 | "exclude": [ 15 | "../app/node_modules" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /docker/nodejs/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:lts-alpine 2 | 3 | RUN npm install pm2 -g \ 4 | && pm2 install pm2-logrotate 5 | 6 | RUN npm install typescript -g 7 | 8 | ENV APP_HOME /opt/app 9 | 10 | WORKDIR $APP_HOME 11 | 12 | COPY docker/nodejs/entrypoint-server.sh /usr/local/bin 13 | RUN chmod -R 777 /usr/local/bin/entrypoint-server.sh 14 | 15 | COPY docker/nodejs/entrypoint-microservices.sh /usr/local/bin 16 | RUN chmod -R 777 /usr/local/bin/entrypoint-microservices.sh 17 | -------------------------------------------------------------------------------- /app-gateway/src/api/products/ProductsRouter.ts: -------------------------------------------------------------------------------- 1 | import express, {Request, Response} from 'express'; 2 | import ProductsController from './ProductsController'; 3 | 4 | const router = express.Router(); 5 | 6 | router.get('/', ProductsController.findAll); 7 | router.get('/:id', ProductsController.findById); 8 | router.post('/', ProductsController.create); 9 | router.put('/', ProductsController.update); 10 | router.delete('/:id', ProductsController.remove); 11 | 12 | 13 | export default router; -------------------------------------------------------------------------------- /app-orders/src/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | register "./controllers" 5 | "google.golang.org/grpc" 6 | "log" 7 | "net" 8 | ) 9 | 10 | const ( 11 | port = ":50054" 12 | ) 13 | 14 | func main() { 15 | lis, err := net.Listen("tcp", port) 16 | if err != nil { 17 | log.Fatalf("failed to listen: %v", err) 18 | } 19 | s := grpc.NewServer() 20 | register.OrdersController(s) 21 | if err := s.Serve(lis); err != nil { 22 | log.Fatalf("failed to serve: %v", err) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app-gateway/src/api/customers/CustomersRouter.ts: -------------------------------------------------------------------------------- 1 | import express, {Request, Response} from 'express'; 2 | import CustomersController from './CustomersController'; 3 | 4 | const router = express.Router(); 5 | 6 | router.get('/', CustomersController.findAll); 7 | router.get('/:id', CustomersController.findById); 8 | router.post('/', CustomersController.create); 9 | router.put('/', CustomersController.update); 10 | router.delete('/:id', CustomersController.remove); 11 | 12 | 13 | export default router; -------------------------------------------------------------------------------- /app-gateway/src/api/users/UsersRouter.ts: -------------------------------------------------------------------------------- 1 | import express, {Request, Response} from 'express'; 2 | import UsersController from './UsersController'; 3 | 4 | const router = express.Router(); 5 | 6 | router.get('/', UsersController.findAll); 7 | router.get('/:id', UsersController.findById); 8 | router.post('/', UsersController.create); 9 | router.put('/', UsersController.update); 10 | router.delete('/:id', UsersController.remove); 11 | router.post('/login', UsersController.login); 12 | 13 | 14 | export default router; -------------------------------------------------------------------------------- /app-gateway/src/api/IndexRouter.ts: -------------------------------------------------------------------------------- 1 | import * as express from 'express'; 2 | import CustomersRouter from './customers/CustomersRouter'; 3 | import OrdersRouter from './orders/OrdersRouter'; 4 | import ProductsRouter from './products/ProductsRouter'; 5 | import UsersRouter from './users/UsersRouter'; 6 | 7 | const router = express.Router(); 8 | 9 | router.use('/customers', CustomersRouter); 10 | router.use('/orders', OrdersRouter); 11 | router.use('/products', ProductsRouter); 12 | router.use('/users', UsersRouter); 13 | 14 | export default router; -------------------------------------------------------------------------------- /app-gateway/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "lib": [ 5 | "esnext" 6 | ], 7 | "module": "commonjs", 8 | "outDir": "build/src", 9 | "skipLibCheck": true, 10 | "esModuleInterop": true, 11 | "moduleResolution": "node", 12 | "resolveJsonModule": true, 13 | "emitDecoratorMetadata": true, 14 | "experimentalDecorators": true, 15 | "sourceMap": true 16 | }, 17 | "include": [ 18 | "**/**/*" 19 | ], 20 | "exclude": [ 21 | ".git", 22 | "build/src", 23 | "node_modules" 24 | ] 25 | } -------------------------------------------------------------------------------- /docker-compose.override.dist.yml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | 3 | services: 4 | nginx-grpc: 5 | environment: 6 | TZ: GMT-3 7 | NGINX_SERVER_NAME: nginx-grpc.localhost 8 | GRPC_SERVER_1: grpc-customers1:40051 9 | GRPC_SERVER_2: grpc-customers2:50051 10 | API_KEY: your key amplify nginx 11 | 12 | api-gateway-grcp: 13 | environment: 14 | DEBUG: 0 15 | TZ: "America/Fortaleza" 16 | MAX_MEMORY_RESTART: 384M 17 | URL_CUSTOMERS: your ip host:8085 18 | URL_USERS: grpc-users:50052 19 | URL_PRODUCTS: grpc-products:50053 20 | URL_ORDERS: grpc-orders:50054 -------------------------------------------------------------------------------- /docker/nginx/config/server.template.conf: -------------------------------------------------------------------------------- 1 | upstream grpcservers { 2 | server ${GRPC_SERVER_1}; 3 | server ${GRPC_SERVER_2}; 4 | } 5 | 6 | server { 7 | listen 80 http2; 8 | server_name ${NGINX_SERVER_NAME}; 9 | 10 | location / { 11 | grpc_pass grpc://grpcservers; 12 | error_page 502 = /error502grpc; 13 | } 14 | 15 | location = /error502grpc { 16 | internal; 17 | default_type application/grpc; 18 | add_header grpc-status 14; 19 | add_header grpc-message "unavailable"; 20 | return 204; 21 | } 22 | 23 | location /nginx_status { 24 | stub_status on; 25 | allow 127.0.0.1; 26 | deny all; 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /docker/go/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:latest 2 | 3 | # Install grpc 4 | RUN go get -u google.golang.org/grpc && \ 5 | go get -u github.com/golang/protobuf/protoc-gen-go 6 | 7 | # Install protoc and zip system library 8 | RUN apt-get update && apt-get install -y zip && \ 9 | mkdir /opt/protoc && cd /opt/protoc && wget https://github.com/protocolbuffers/protobuf/releases/download/v3.7.0/protoc-3.7.0-linux-x86_64.zip && \ 10 | unzip protoc-3.7.0-linux-x86_64.zip 11 | 12 | ENV PATH=$PATH:$GOPATH/bin:/opt/protoc/bin 13 | ENV APP_HOME /opt/app 14 | 15 | WORKDIR $APP_HOME 16 | 17 | COPY docker/go/entrypoint-server.sh /usr/local/bin 18 | RUN chmod -R 777 /usr/local/bin/entrypoint-server.sh -------------------------------------------------------------------------------- /app-gateway/ecosystem.config.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config(); 2 | 3 | module.exports = { 4 | 5 | apps: [{ 6 | name: 'api-gateway', 7 | script: './build/src/Index.js', 8 | node_args: `--max_old_space_size=${Math.round((Number(process.env.MAX_MEMORY_RESTART.replace(/\D/g, ''))*0.60))}`, 9 | instances : "2", 10 | exec_mode : "cluster", 11 | autorestart: true, 12 | watch: false, 13 | max_memory_restart: process.env.MAX_MEMORY_RESTART, 14 | log_date_format: 'YYYY-MM-DD HH:mm:ss', 15 | out_file: '/opt/app/logs/access.log', 16 | error_file: '/opt/app/logs/app.log', 17 | merge_logs: true, 18 | env: { 19 | NODE_ENV: 'production' 20 | } 21 | }] 22 | }; -------------------------------------------------------------------------------- /docker/nodejs/entrypoint-server.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | cd /opt/app 4 | 5 | echo "Install packaged..." 6 | yarn 7 | 8 | if [ "$NODE_ENV" != "production" ] && [ "$DEBUG" = '0' ]; then 9 | echo "Start development application server..." 10 | yarn dev 11 | fi 12 | 13 | if [ "$NODE_ENV" != "production" ] && [ "$DEBUG" = '1' ]; then 14 | echo "Start debug application server..." 15 | yarn debug 16 | fi 17 | 18 | if [ "$NODE_ENV" = "production" ]; then 19 | echo "Creating paths..." 20 | mkdir -p $APP_HOME/logs; 21 | mkdir -p $APP_HOME/build; 22 | 23 | yarn clean && yarn build; 24 | 25 | # Copy files *.proto 26 | cp -R $APP_HOME/src/config/grpc/proto/ $APP_HOME/build/src/config/grpc/ 27 | 28 | echo "Start production application server..." 29 | yarn start; 30 | fi 31 | 32 | exec "$@" -------------------------------------------------------------------------------- /app-products/src/server.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import time 3 | import grpc 4 | from concurrent import futures 5 | from controllers.ProductsController import ProductsController 6 | 7 | 8 | def serverCreate(host='[::]:50053'): 9 | server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) 10 | ProductsController.register(server) 11 | server.add_insecure_port(host) 12 | return server 13 | 14 | 15 | if __name__ == '__main__': 16 | port = sys.argv[1] if len(sys.argv) > 1 else 50053 17 | host = '[::]:%s' % port 18 | server = serverCreate(host) 19 | try: 20 | server.start() 21 | print('Running Discount service on %s' % host) 22 | while True: 23 | time.sleep(1) 24 | except Exception as e: 25 | print('[error] %s' % e) 26 | server.stop(0) 27 | -------------------------------------------------------------------------------- /app-gateway/src/api/orders/OrdersService.ts: -------------------------------------------------------------------------------- 1 | import 'dotenv/config'; 2 | import LoadClientGRPC from '../../config/grpc/LoadClientGRPC'; 3 | 4 | const ordersClient: any = LoadClientGRPC.loadClient({ 5 | serviceName: 'Orders', 6 | address: process.env.URL_ORDERS || 'grpc-orders:50054', 7 | fileName: 'orders' 8 | }); 9 | 10 | export default class OrdersService { 11 | public static async findAll(): Promise { 12 | const response = await ordersClient.getAll({}); 13 | 14 | if (response !== undefined && response.ordersResponseList !== undefined) { 15 | return Promise.resolve(response.ordersResponseList); 16 | } 17 | 18 | return Promise.resolve([]); 19 | } 20 | 21 | public static async create(ordersRequest: any): Promise { 22 | return ordersClient.insert(ordersRequest); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /app-gateway/src/App.ts: -------------------------------------------------------------------------------- 1 | import compression from 'compression'; 2 | import cors from 'cors'; 3 | import 'dotenv/config'; 4 | import express from 'express'; 5 | import helmet from 'helmet'; 6 | import IndexRouter from './api/IndexRouter'; 7 | 8 | export default class App { 9 | 10 | public constructor(port: number) { 11 | this.app = express(); 12 | this.app.set('port', port) 13 | this.applyMiddleware(); 14 | this.router(); 15 | } 16 | 17 | public app: express.Application; 18 | 19 | private applyMiddleware(): void { 20 | this.app.use(express.json()); 21 | this.app.use(express.urlencoded({extended: true})); 22 | this.app.use(cors()); 23 | this.app.use(helmet()); 24 | this.app.use(compression()); 25 | } 26 | 27 | private router(): void { 28 | this.app.use('/', IndexRouter); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /app-gateway/src/api/orders/OrdersController.ts: -------------------------------------------------------------------------------- 1 | import {NextFunction, Request, Response} from 'express'; 2 | import * as HttpStatus from 'http-status-codes'; 3 | import OrdersService from './OrdersService'; 4 | 5 | 6 | export default class OrdersController { 7 | 8 | public static async findAll(req: Request, res: Response, next: NextFunction): Promise { 9 | try { 10 | const response = await OrdersService.findAll(); 11 | res.status(HttpStatus.OK).send(response); 12 | } catch (error) { 13 | next(error); 14 | } 15 | } 16 | 17 | public static async create(req: Request, res: Response, next: NextFunction): Promise { 18 | try { 19 | const response = await OrdersService.create(req.body); 20 | res.status(HttpStatus.CREATED).send(response); 21 | } catch (error) { 22 | next(error); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app-gateway/src/config/grpc/proto/products.proto: -------------------------------------------------------------------------------- 1 | syntax = 'proto3'; 2 | 3 | service Products { 4 | rpc GetAll (Empty) returns (ProductsResponseList) {} 5 | rpc Get (ProductsRequestId) returns (ProductsResponse) {} 6 | rpc Insert (ProductsInsertRequest) returns (ProductsResponse) {} 7 | rpc Update (ProductsUpdateRequest) returns (ProductsResponse) {} 8 | rpc Remove (ProductsRequestId) returns (Empty) {} 9 | } 10 | 11 | message Empty {} 12 | 13 | message ProductsInsertRequest { 14 | string name = 1; 15 | float price = 2; 16 | } 17 | 18 | message ProductsUpdateRequest { 19 | string id = 1; 20 | string name = 2; 21 | float price = 3; 22 | } 23 | 24 | message ProductsRequestId { 25 | string id = 1; 26 | } 27 | 28 | message ProductsResponse { 29 | string id = 1; 30 | string name = 2; 31 | float price = 3; 32 | } 33 | 34 | message ProductsResponseList { 35 | repeated ProductsResponse productsResponseList = 1; 36 | } -------------------------------------------------------------------------------- /app-products/src/proto/products/products.proto: -------------------------------------------------------------------------------- 1 | syntax = 'proto3'; 2 | 3 | service Products { 4 | rpc GetAll (Empty) returns (ProductsResponseList) {} 5 | rpc Get (ProductsRequestId) returns (ProductsResponse) {} 6 | rpc Insert (ProductsInsertRequest) returns (ProductsResponse) {} 7 | rpc Update (ProductsUpdateRequest) returns (ProductsResponse) {} 8 | rpc Remove (ProductsRequestId) returns (Empty) {} 9 | } 10 | 11 | message Empty {} 12 | 13 | message ProductsInsertRequest { 14 | string name = 1; 15 | float price = 2; 16 | } 17 | 18 | message ProductsUpdateRequest { 19 | string id = 1; 20 | string name = 2; 21 | float price = 3; 22 | } 23 | 24 | message ProductsRequestId { 25 | string id = 1; 26 | } 27 | 28 | message ProductsResponse { 29 | string id = 1; 30 | string name = 2; 31 | float price = 3; 32 | } 33 | 34 | message ProductsResponseList { 35 | repeated ProductsResponse productsResponseList = 1; 36 | } -------------------------------------------------------------------------------- /app-users/scripts/protoc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BASEDIR=$(dirname "$0") 4 | cd "${BASEDIR}"/../ 5 | 6 | PROTOC_GEN_TS_PATH="./node_modules/.bin/protoc-gen-ts" 7 | GRPC_TOOLS_NODE_PROTOC_PLUGIN="./node_modules/.bin/grpc_tools_node_protoc_plugin" 8 | GRPC_TOOLS_NODE_PROTOC="./node_modules/.bin/grpc_tools_node_protoc" 9 | 10 | for f in ./src/proto/*; do 11 | 12 | # skip the non proto files 13 | if [ "$(basename "$f")" == "index.ts" ]; then 14 | continue 15 | fi 16 | 17 | # JavaScript code generating 18 | ${GRPC_TOOLS_NODE_PROTOC} \ 19 | --js_out=import_style=commonjs,binary:"${f}" \ 20 | --grpc_out="${f}" \ 21 | --plugin=protoc-gen-grpc="${GRPC_TOOLS_NODE_PROTOC_PLUGIN}" \ 22 | -I "${f}" \ 23 | "${f}"/*.proto 24 | 25 | ${GRPC_TOOLS_NODE_PROTOC} \ 26 | --plugin=protoc-gen-ts="${PROTOC_GEN_TS_PATH}" \ 27 | --ts_out="${f}" \ 28 | -I "${f}" \ 29 | "${f}"/*.proto 30 | 31 | done 32 | -------------------------------------------------------------------------------- /app-customers/scripts/protoc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BASEDIR=$(dirname "$0") 4 | cd "${BASEDIR}"/../ 5 | 6 | PROTOC_GEN_TS_PATH="./node_modules/.bin/protoc-gen-ts" 7 | GRPC_TOOLS_NODE_PROTOC_PLUGIN="./node_modules/.bin/grpc_tools_node_protoc_plugin" 8 | GRPC_TOOLS_NODE_PROTOC="./node_modules/.bin/grpc_tools_node_protoc" 9 | 10 | for f in ./src/proto/*; do 11 | 12 | # skip the non proto files 13 | if [ "$(basename "$f")" == "index.ts" ]; then 14 | continue 15 | fi 16 | 17 | # JavaScript code generating 18 | ${GRPC_TOOLS_NODE_PROTOC} \ 19 | --js_out=import_style=commonjs,binary:"${f}" \ 20 | --grpc_out="${f}" \ 21 | --plugin=protoc-gen-grpc="${GRPC_TOOLS_NODE_PROTOC_PLUGIN}" \ 22 | -I "${f}" \ 23 | "${f}"/*.proto 24 | 25 | ${GRPC_TOOLS_NODE_PROTOC} \ 26 | --plugin=protoc-gen-ts="${PROTOC_GEN_TS_PATH}" \ 27 | --ts_out="${f}" \ 28 | -I "${f}" \ 29 | "${f}"/*.proto 30 | 31 | done 32 | -------------------------------------------------------------------------------- /app-users/src/server.ts: -------------------------------------------------------------------------------- 1 | import 'dotenv/config'; 2 | import * as grpc from 'grpc'; 3 | import {protoIndex} from './proto'; 4 | import UsersController from './controllers/UsersController'; 5 | 6 | protoIndex(); 7 | 8 | const port: string | number = process.env.PORT || 50052; 9 | 10 | export const startServer = (): void => { 11 | const server: grpc.Server = new grpc.Server(); 12 | 13 | /*TODO: Register controllers*/ 14 | server.addService(UsersController.service, UsersController.server); 15 | 16 | server.bindAsync( 17 | `0.0.0.0:${port}`, 18 | grpc.ServerCredentials.createInsecure(), 19 | (err: Error, port: number) => { 20 | if (err != null) { 21 | return console.error(`Error start application: ${err}`); 22 | } 23 | console.warn(`Microservice users gRPC listening on ${port}`); 24 | }, 25 | ); 26 | 27 | server.start(); 28 | }; 29 | 30 | startServer(); 31 | -------------------------------------------------------------------------------- /app-customers/src/server.ts: -------------------------------------------------------------------------------- 1 | import 'dotenv/config'; 2 | import * as grpc from 'grpc'; 3 | import {protoIndex} from './proto'; 4 | import CustomersController from './controllers/CustomersController'; 5 | 6 | protoIndex(); 7 | 8 | const port: string | number = process.env.PORT || 50051; 9 | 10 | export const startServer = (): void => { 11 | const server: grpc.Server = new grpc.Server(); 12 | 13 | /*TODO: Register controllers*/ 14 | server.addService(CustomersController.service, CustomersController.server); 15 | 16 | server.bindAsync( 17 | `0.0.0.0:${port}`, 18 | grpc.ServerCredentials.createInsecure(), 19 | (err: Error, port: number) => { 20 | if (err != null) { 21 | return console.error(`Error start application: ${err}`); 22 | } 23 | console.warn(`Microservice customers gRPC listening on ${port}`); 24 | }, 25 | ); 26 | 27 | server.start(); 28 | }; 29 | 30 | startServer(); 31 | -------------------------------------------------------------------------------- /app-users/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grpc-users", 3 | "version": "1.0.0", 4 | "description": "gRPC typescript start with nodejs example", 5 | "main": "server.js", 6 | "scripts": { 7 | "dev": "ts-node-dev --respawn --transpileOnly src/server.ts", 8 | "build": "npx tsc --skipLibCheck", 9 | "start": "npx tsc --skipLibCheck && node ./dist/server.js", 10 | "protoc": "scripts/protoc.sh" 11 | }, 12 | "keywords": [], 13 | "author": "Hemicharly Thiago", 14 | "license": "ISC", 15 | "dependencies": { 16 | "dotenv": "^8.2.0", 17 | "google-protobuf": "^3.12.1", 18 | "grpc": "^1.24.9", 19 | "uuid": "^8.1.0" 20 | }, 21 | "devDependencies": { 22 | "@types/uuid": "^8.0.0", 23 | "@types/google-protobuf": "^3.7.2", 24 | "@types/node": "^14.0.5", 25 | "@types/nodemon": "^1.19.0", 26 | "grpc-tools": "^1.9.0", 27 | "grpc_tools_node_protoc_ts": "^3.0.0", 28 | "ts-node-dev": "^1.0.0-pre.44", 29 | "ts-node": "^8.10.1", 30 | "typescript": "^3.9.3" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app-customers/src/proto/customers/customers.proto: -------------------------------------------------------------------------------- 1 | syntax = 'proto3'; 2 | 3 | service Customers { 4 | rpc GetAll (Empty) returns (CustomersResponseList) {} 5 | rpc Get (CustomersRequestId) returns (CustomersResponse) {} 6 | rpc Insert (CustomersInsertRequest) returns (CustomersResponse) {} 7 | rpc Update (CustomersUpdateRequest) returns (CustomersResponse) {} 8 | rpc Remove (CustomersRequestId) returns (Empty) {} 9 | } 10 | 11 | message Empty {} 12 | 13 | message CustomersInsertRequest { 14 | string name = 1; 15 | int32 age = 2; 16 | string address = 3; 17 | } 18 | 19 | message CustomersUpdateRequest { 20 | string id = 1; 21 | string name = 2; 22 | int32 age = 3; 23 | string address = 4; 24 | } 25 | 26 | message CustomersRequestId { 27 | string id = 1; 28 | } 29 | 30 | message CustomersResponse { 31 | string id = 1; 32 | string name = 2; 33 | int32 age = 3; 34 | string address = 4; 35 | } 36 | 37 | message CustomersResponseList { 38 | repeated CustomersResponse customersResponseList = 1; 39 | } -------------------------------------------------------------------------------- /app-gateway/src/config/grpc/proto/customers.proto: -------------------------------------------------------------------------------- 1 | syntax = 'proto3'; 2 | 3 | service Customers { 4 | rpc GetAll (Empty) returns (CustomersResponseList) {} 5 | rpc Get (CustomersRequestId) returns (CustomersResponse) {} 6 | rpc Insert (CustomersInsertRequest) returns (CustomersResponse) {} 7 | rpc Update (CustomersUpdateRequest) returns (CustomersResponse) {} 8 | rpc Remove (CustomersRequestId) returns (Empty) {} 9 | } 10 | 11 | message Empty {} 12 | 13 | message CustomersInsertRequest { 14 | string name = 1; 15 | int32 age = 2; 16 | string address = 3; 17 | } 18 | 19 | message CustomersUpdateRequest { 20 | string id = 1; 21 | string name = 2; 22 | int32 age = 3; 23 | string address = 4; 24 | } 25 | 26 | message CustomersRequestId { 27 | string id = 1; 28 | } 29 | 30 | message CustomersResponse { 31 | string id = 1; 32 | string name = 2; 33 | int32 age = 3; 34 | string address = 4; 35 | } 36 | 37 | message CustomersResponseList { 38 | repeated CustomersResponse customersResponseList = 1; 39 | } -------------------------------------------------------------------------------- /app-customers/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grpc-customers", 3 | "version": "1.0.0", 4 | "description": "gRPC typescript start with nodejs example", 5 | "main": "server.js", 6 | "scripts": { 7 | "dev": "ts-node-dev --respawn --transpileOnly src/server.ts", 8 | "build": "npx tsc --skipLibCheck", 9 | "start": "npx tsc --skipLibCheck && node ./dist/server.js", 10 | "protoc": "scripts/protoc.sh" 11 | }, 12 | "keywords": [], 13 | "author": "Hemicharly Thiago", 14 | "license": "ISC", 15 | "dependencies": { 16 | "dotenv": "^8.2.0", 17 | "google-protobuf": "^3.12.1", 18 | "grpc": "^1.24.9", 19 | "uuid": "^8.1.0" 20 | }, 21 | "devDependencies": { 22 | "@types/uuid": "^8.0.0", 23 | "@types/google-protobuf": "^3.7.2", 24 | "@types/node": "^14.0.5", 25 | "@types/nodemon": "^1.19.0", 26 | "grpc-tools": "^1.9.0", 27 | "grpc_tools_node_protoc_ts": "^3.0.0", 28 | "ts-node-dev": "^1.0.0-pre.44", 29 | "ts-node": "^8.10.1", 30 | "typescript": "^3.9.3" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app-orders/src/proto/orders.proto: -------------------------------------------------------------------------------- 1 | syntax = 'proto3'; 2 | 3 | service Orders { 4 | rpc GetAll(Empty) returns (OrdersResponseList) {} 5 | rpc Insert (OrdersRequest) returns (OrdersResponse) {} 6 | } 7 | 8 | message Empty {} 9 | 10 | message OrdersItemRequest { 11 | string productsId = 1; 12 | float price = 2; 13 | int32 quantity = 3; 14 | } 15 | 16 | message OrdersItemResponse { 17 | string id = 1; 18 | string ordersId = 2; 19 | string productsId = 3; 20 | float price = 4; 21 | int32 quantity = 5; 22 | float totalItem = 6; 23 | } 24 | 25 | message OrdersRequest { 26 | string customersId = 1; 27 | string dateOrders = 2; 28 | repeated OrdersItemRequest ordersItemRequestList = 3; 29 | } 30 | 31 | message OrdersResponse { 32 | string id = 1; 33 | string customersId = 2; 34 | string dateOrders = 3; 35 | repeated OrdersItemResponse ordersItemResponse = 4; 36 | float totalOrders = 5; 37 | } 38 | 39 | message OrdersResponseList { 40 | repeated OrdersResponse ordersResponseList = 1; 41 | } 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /app-gateway/src/config/grpc/proto/orders.proto: -------------------------------------------------------------------------------- 1 | syntax = 'proto3'; 2 | 3 | service Orders { 4 | rpc GetAll(Empty) returns (OrdersResponseList) {} 5 | rpc Insert (OrdersRequest) returns (OrdersResponse) {} 6 | } 7 | 8 | message Empty {} 9 | 10 | message OrdersItemRequest { 11 | string productsId = 1; 12 | float price = 2; 13 | int32 quantity = 3; 14 | } 15 | 16 | message OrdersItemResponse { 17 | string id = 1; 18 | string ordersId = 2; 19 | string productsId = 3; 20 | float price = 4; 21 | int32 quantity = 5; 22 | float totalItem = 6; 23 | } 24 | 25 | message OrdersRequest { 26 | string customersId = 1; 27 | string dateOrders = 2; 28 | repeated OrdersItemRequest ordersItemRequestList = 3; 29 | } 30 | 31 | message OrdersResponse { 32 | string id = 1; 33 | string customersId = 2; 34 | string dateOrders = 3; 35 | repeated OrdersItemResponse ordersItemResponse = 4; 36 | float totalOrders = 5; 37 | } 38 | 39 | message OrdersResponseList { 40 | repeated OrdersResponse ordersResponseList = 1; 41 | } 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /app-users/src/proto/users/users.proto: -------------------------------------------------------------------------------- 1 | syntax = 'proto3'; 2 | 3 | service Users { 4 | rpc GetAll (Empty) returns (UsersResponseList) {} 5 | rpc Get (UsersRequestId) returns (UsersResponse) {} 6 | rpc Insert (UsersInsertRequest) returns (UsersResponse) {} 7 | rpc Update (UsersUpdateRequest) returns (UsersResponse) {} 8 | rpc Remove (UsersRequestId) returns (Empty) {} 9 | rpc Login (UsersLoginRequest) returns (UsersResponse){} 10 | } 11 | 12 | message Empty {} 13 | 14 | message UsersInsertRequest { 15 | string username = 1; 16 | string password = 2; 17 | string email = 3; 18 | } 19 | 20 | message UsersLoginRequest { 21 | string username = 1; 22 | string password = 2; 23 | } 24 | 25 | message UsersUpdateRequest { 26 | string id = 1; 27 | string username = 2; 28 | string password = 3; 29 | string email = 4; 30 | } 31 | 32 | message UsersRequestId { 33 | string id = 1; 34 | } 35 | 36 | message UsersResponse { 37 | string id = 1; 38 | string username = 2; 39 | string email = 3; 40 | } 41 | 42 | message UsersResponseList { 43 | repeated UsersResponse usersResponseList = 1; 44 | } -------------------------------------------------------------------------------- /app-gateway/src/config/grpc/proto/users.proto: -------------------------------------------------------------------------------- 1 | syntax = 'proto3'; 2 | 3 | service Users { 4 | rpc GetAll (Empty) returns (UsersResponseList) {} 5 | rpc Get (UsersRequestId) returns (UsersResponse) {} 6 | rpc Insert (UsersInsertRequest) returns (UsersResponse) {} 7 | rpc Update (UsersUpdateRequest) returns (UsersResponse) {} 8 | rpc Remove (UsersRequestId) returns (Empty) {} 9 | rpc Login (UsersLoginRequest) returns (UsersResponse){} 10 | } 11 | 12 | message Empty {} 13 | 14 | message UsersInsertRequest { 15 | string username = 1; 16 | string password = 2; 17 | string email = 3; 18 | } 19 | 20 | message UsersLoginRequest { 21 | string username = 1; 22 | string password = 2; 23 | } 24 | 25 | message UsersUpdateRequest { 26 | string id = 1; 27 | string username = 2; 28 | string password = 3; 29 | string email = 4; 30 | } 31 | 32 | message UsersRequestId { 33 | string id = 1; 34 | } 35 | 36 | message UsersResponse { 37 | string id = 1; 38 | string username = 2; 39 | string email = 3; 40 | } 41 | 42 | message UsersResponseList { 43 | repeated UsersResponse usersResponseList = 1; 44 | } -------------------------------------------------------------------------------- /docker/nginx/config/nginx.conf: -------------------------------------------------------------------------------- 1 | user nginx; 2 | pid /run/nginx.pid; 3 | 4 | worker_processes auto; 5 | worker_rlimit_nofile 100000; 6 | error_log /var/log/nginx/error.log warn; 7 | 8 | events { 9 | worker_connections 4096; 10 | use epoll; 11 | multi_accept on; 12 | } 13 | 14 | http { 15 | log_format main_ext '$remote_addr - $remote_user [$time_local] "$request" ' 16 | '$status $body_bytes_sent "$http_referer" ' 17 | '"$http_user_agent" "$http_x_forwarded_for" ' 18 | '"$host" sn="$server_name" ' 19 | 'rt=$request_time ' 20 | 'ua="$upstream_addr" us="$upstream_status" ' 21 | 'ut="$upstream_response_time" ul="$upstream_response_length" ' 22 | 'cs=$upstream_cache_status' ; 23 | 24 | access_log /var/log/nginx/access.log main_ext; 25 | 26 | map $http_upgrade $connection_upgrade { 27 | default upgrade; 28 | '' close; 29 | } 30 | 31 | # Include setting server_host 32 | include /etc/nginx/sites-enabled/*; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /app-gateway/src/config/grpc/LoadClientGRPC.ts: -------------------------------------------------------------------------------- 1 | import * as protoLoader from '@grpc/proto-loader'; 2 | import * as grpc from 'grpc'; 3 | import path from 'path'; 4 | import {promisify} from 'util'; 5 | import {ILoadClientGRPC} from './ILoadClientGRPC'; 6 | 7 | 8 | export default class LoadClientGRPC { 9 | protected static PROTO_CONFIG: any = { 10 | keepCase: false, 11 | longs: String, 12 | enums: String, 13 | defaults: true, 14 | oneofs: true, 15 | } 16 | 17 | public static loadClient({serviceName, fileName, address, credentials = grpc.credentials.createInsecure()}: ILoadClientGRPC): any { 18 | const protoDef: any = protoLoader.loadSync(path.resolve(__dirname, 'proto', `${fileName}.proto`), this.PROTO_CONFIG); 19 | 20 | const protoLoad: any = grpc.loadPackageDefinition(protoDef); 21 | 22 | const clientGRPC: any = new protoLoad[serviceName](address, credentials); 23 | 24 | const clientProto: any = Object.entries(clientGRPC.__proto__); 25 | clientProto.map(([prop, value]) => { 26 | if (value !== undefined && value.originalName !== undefined) { 27 | clientGRPC[prop] = promisify(value); 28 | } 29 | }); 30 | 31 | return clientGRPC; 32 | } 33 | } -------------------------------------------------------------------------------- /app-gateway/src/api/products/ProductsService.ts: -------------------------------------------------------------------------------- 1 | import 'dotenv/config'; 2 | import LoadClientGRPC from '../../config/grpc/LoadClientGRPC'; 3 | 4 | const productsClient: any = LoadClientGRPC.loadClient({ 5 | serviceName: 'Products', 6 | address: process.env.URL_PRODUCTS || 'grpc-products:50053', 7 | fileName: 'products' 8 | }); 9 | 10 | export default class ProductsService { 11 | public static async findAll(): Promise { 12 | const response = await productsClient.getAll({}); 13 | 14 | if (response !== undefined && response.productsResponseList !== undefined) { 15 | return Promise.resolve(response.productsResponseList); 16 | } 17 | 18 | return Promise.resolve([]); 19 | } 20 | 21 | public static async findById(id: string): Promise { 22 | return productsClient.get({id}); 23 | } 24 | 25 | public static async create(productsRequest: any): Promise { 26 | return productsClient.insert(productsRequest); 27 | } 28 | 29 | public static async update(productsRequest: any): Promise { 30 | return productsClient.update(productsRequest); 31 | } 32 | 33 | public static async remove(id: string): Promise { 34 | return productsClient.remove({id}); 35 | } 36 | } -------------------------------------------------------------------------------- /app-gateway/src/api/customers/CustomersService.ts: -------------------------------------------------------------------------------- 1 | import 'dotenv/config'; 2 | import LoadClientGRPC from '../../config/grpc/LoadClientGRPC'; 3 | 4 | const customersClient: any = LoadClientGRPC.loadClient({ 5 | serviceName: 'Customers', 6 | address: process.env.URL_CUSTOMERS || 'grpc-customers:50051', 7 | fileName: 'customers' 8 | }); 9 | 10 | export default class CustomersService { 11 | public static async findAll(): Promise { 12 | const response = await customersClient.getAll({}); 13 | 14 | if (response !== undefined && response.customersResponseList !== undefined) { 15 | return Promise.resolve(response.customersResponseList); 16 | } 17 | 18 | return Promise.resolve([]); 19 | } 20 | 21 | public static async findById(id: string): Promise { 22 | return customersClient.get({id}); 23 | } 24 | 25 | public static async create(customersRequest: any): Promise { 26 | return customersClient.insert(customersRequest); 27 | } 28 | 29 | public static async update(customersRequest: any): Promise { 30 | return customersClient.update(customersRequest); 31 | } 32 | 33 | public static async remove(id: string): Promise { 34 | return customersClient.remove({id}); 35 | } 36 | } -------------------------------------------------------------------------------- /app-gateway/src/api/users/UsersService.ts: -------------------------------------------------------------------------------- 1 | import 'dotenv/config'; 2 | import LoadClientGRPC from '../../config/grpc/LoadClientGRPC'; 3 | 4 | const usersClient: any = LoadClientGRPC.loadClient({ 5 | serviceName: 'Users', 6 | address: process.env.URL_USERS || 'grpc-users:50052', 7 | fileName: 'users' 8 | }); 9 | 10 | export default class UsersService { 11 | public static async findAll(): Promise { 12 | const response = await usersClient.getAll({}); 13 | 14 | if (response !== undefined && response.usersResponseList !== undefined) { 15 | return Promise.resolve(response.usersResponseList); 16 | } 17 | 18 | return Promise.resolve([]); 19 | } 20 | 21 | public static async findById(id: string): Promise { 22 | return usersClient.get({id}); 23 | } 24 | 25 | public static async create(usersRequest: any): Promise { 26 | return usersClient.insert(usersRequest); 27 | } 28 | 29 | public static async update(usersRequest: any): Promise { 30 | return usersClient.update(usersRequest); 31 | } 32 | 33 | public static async remove(id: string): Promise { 34 | return usersClient.remove({id}); 35 | } 36 | 37 | public static async login(usersRequest: any): Promise { 38 | return usersClient.login(usersRequest); 39 | } 40 | } -------------------------------------------------------------------------------- /docker/nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:1.18.0 2 | 3 | # Install the NGINX Amplify Agent 4 | RUN apt-get update \ 5 | && apt-get install -qqy curl python apt-transport-https apt-utils gnupg1 procps \ 6 | && echo 'deb https://packages.amplify.nginx.com/debian/ stretch amplify-agent' > /etc/apt/sources.list.d/nginx-amplify.list \ 7 | && curl -fs https://nginx.org/keys/nginx_signing.key | apt-key add - > /dev/null 2>&1 \ 8 | && apt-get update \ 9 | && apt-get install -qqy nginx-amplify-agent \ 10 | && apt-get purge -qqy curl apt-transport-https apt-utils gnupg1 \ 11 | && rm -rf /etc/apt/sources.list.d/nginx-amplify.list \ 12 | && rm -rf /var/lib/apt/lists/* 13 | 14 | # Keep the nginx logs inside the container 15 | RUN unlink /var/log/nginx/access.log \ 16 | && unlink /var/log/nginx/error.log \ 17 | && touch /var/log/nginx/access.log \ 18 | && touch /var/log/nginx/error.log \ 19 | && chown nginx /var/log/nginx/*log \ 20 | && chmod 644 /var/log/nginx/*log 21 | 22 | RUN rm /etc/nginx/conf.d/default.conf \ 23 | && mkdir -p /etc/nginx/sites-enabled 24 | 25 | COPY docker/nginx/config/nginx.conf /etc/nginx/nginx.conf 26 | COPY docker/nginx/config/server.template.conf /etc/nginx/server.template.conf 27 | 28 | COPY docker/nginx/entrypoint.sh /usr/local/bin 29 | RUN chmod -R 777 /usr/local/bin/entrypoint.sh 30 | 31 | ENTRYPOINT ["entrypoint.sh"] 32 | -------------------------------------------------------------------------------- /app-gateway/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "app-gateway", 3 | "version": "0.0.1", 4 | "license": "MIT", 5 | "description": "app-gateway to consume gRPC microservices", 6 | "author": "Hemicharly Thiago", 7 | "main": "Index.js", 8 | "scripts": { 9 | "debug": "ts-node-dev --inspect=0.0.0.0 --respawn --transpileOnly src/Index.ts", 10 | "dev": "ts-node-dev --respawn --transpileOnly src/Index.ts", 11 | "lint": "tslint --project tsconfig.json", 12 | "lint:fix": "yarn lint --fix", 13 | "clean": "rm -rf build/*", 14 | "build": "tsc", 15 | "start": "pm2-runtime start ecosystem.config.js --env production" 16 | }, 17 | "dependencies": { 18 | "@grpc/proto-loader": "^0.5.3", 19 | "express": "^4.17.1", 20 | "grpc": "^1.24.9", 21 | "http-status-codes": "^1.4.0", 22 | "uuid": "^7.0.2", 23 | "dotenv": "^8.2.0", 24 | "compression": "^1.7.4", 25 | "cors": "^2.8.5", 26 | "helmet": "^3.21.3" 27 | }, 28 | "devDependencies": { 29 | "@types/compression": "^1.7.0", 30 | "@types/cors": "^2.8.6", 31 | "@types/helmet": "^0.0.45", 32 | "@types/node": "^13.9.0", 33 | "minimist": ">=1.2.2", 34 | "@types/redis": "^2.8.16", 35 | "@types/uuid": "^7.0.2", 36 | "ts-node": "^8.6.2", 37 | "ts-node-dev": "^1.0.0-pre.44", 38 | "tslint": "^5.20.1", 39 | "tslint-config-prettier": "^1.18.0", 40 | "tslint-config-standard": "^9.0.0", 41 | "tslint-sonarts": "^1.9.0", 42 | "typescript": "^3.8.3" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app-products/src/controllers/ProductsController.py: -------------------------------------------------------------------------------- 1 | from proto.products import products_pb2_grpc, products_pb2 2 | 3 | 4 | class ProductsServices(products_pb2_grpc.ProductsServicer): 5 | 6 | def GetAll(self, request, context): 7 | listProducts = [] 8 | for item in range(10): 9 | product = products_pb2.ProductsResponse(id=str((item + 1)), name='cpu' + str(item + 1), 10 | price=((item + 1) * 2)) 11 | listProducts.append(product) 12 | return products_pb2.ProductsResponseList(productsResponseList=[product for product in listProducts]) 13 | 14 | def Get(self, request, context): 15 | products = products_pb2.ProductsResponse(id=request.id, name='cpu', price=123) 16 | return products 17 | 18 | def Insert(self, request, context): 19 | products = products_pb2.ProductsResponse(id='1235', name=request.name, price=request.price) 20 | return products 21 | 22 | def Update(self, request, context): 23 | products = products_pb2.ProductsResponse(id=request.id, name=request.name, price=request.price) 24 | return products 25 | 26 | def Remove(self, request, context): 27 | print ('Remove product {0}'.format(request.id)) 28 | products = products_pb2.Empty() 29 | return products 30 | 31 | 32 | class ProductsController(object): 33 | 34 | @classmethod 35 | def register(cls, server): 36 | products_pb2_grpc.add_ProductsServicer_to_server(ProductsServices(), server) 37 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Execute all application in mode development 2 | dev: 3 | docker-compose up --build 4 | 5 | # Execute grpc-customers application in mode development 6 | dev-grpc-customers: 7 | docker-compose up --build grpc-customers1 customers2 8 | 9 | # Execute grpc-users application in mode development 10 | dev-grpc-users: 11 | docker-compose up --build grpc-users 12 | 13 | # Execute grpc-products application in mode development 14 | dev-grpc-products: 15 | docker-compose up --build grpc-products 16 | 17 | # Execute grpc-orders application in mode development 18 | dev-grpc-orders: 19 | docker-compose up --build grpc-orders 20 | 21 | # Execute api-gateway-grcp application in mode development 22 | dev-api-gateway-grcp: 23 | NODE_ENV=development docker-compose up --build api-gateway-grcp 24 | 25 | # Execute api-gateway-grcp application in mode production 26 | prod-api-gateway-grcp: 27 | NODE_ENV=production docker-compose up --build api-gateway-grcp 28 | 29 | # Execute nginx-grpc application using hostname 30 | nginx-start: 31 | export HOST_NAME=$(HOST_NAME); \ 32 | docker-compose up --build nginx-grpc 33 | 34 | #################################################################################### 35 | # Execute command lint:fix in gateway api 36 | lint-fix-api-gateway: 37 | docker-compose exec api-gateway-grcp yarn lint:fix 38 | 39 | 40 | 41 | #################################################################################### 42 | # Execute command yarn protoc to app-customers 43 | protoc-grpc-customers: 44 | cd app-customers && yarn protoc 45 | 46 | # Execute command yarn protoc to app-users 47 | protoc-grpc-users: 48 | cd app-users && yarn protoc 49 | 50 | # Execute command script/protoc.sh to app-products 51 | protoc-grpc-products: 52 | app-products/scripts/protoc.sh -------------------------------------------------------------------------------- /app-gateway/src/api/products/ProductsController.ts: -------------------------------------------------------------------------------- 1 | import {NextFunction, Request, Response} from 'express'; 2 | import * as HttpStatus from 'http-status-codes'; 3 | import ProductsService from './ProductsService'; 4 | 5 | 6 | 7 | export default class ProductsController { 8 | 9 | public static async findAll(req: Request, res: Response, next: NextFunction): Promise { 10 | try { 11 | const response = await ProductsService.findAll(); 12 | res.status(HttpStatus.OK).send(response); 13 | } catch (error) { 14 | next(error); 15 | } 16 | } 17 | 18 | public static async findById(req: Request, res: Response, next: NextFunction): Promise { 19 | try { 20 | const response = await ProductsService.findById(req.params.id); 21 | res.status(HttpStatus.OK).send(response); 22 | } catch (error) { 23 | next(error); 24 | } 25 | } 26 | 27 | public static async create(req: Request, res: Response, next: NextFunction): Promise { 28 | try { 29 | const response = await ProductsService.create(req.body); 30 | res.status(HttpStatus.CREATED).send(response); 31 | } catch (error) { 32 | next(error); 33 | } 34 | } 35 | 36 | public static async update(req: Request, res: Response, next: NextFunction): Promise { 37 | try { 38 | const response = await ProductsService.update(req.body); 39 | res.status(HttpStatus.CREATED).send(response); 40 | } catch (error) { 41 | next(error); 42 | } 43 | } 44 | 45 | public static async remove(req: Request, res: Response, next: NextFunction): Promise { 46 | try { 47 | const response = await ProductsService.remove(req.params.id); 48 | res.status(HttpStatus.OK).send(response); 49 | } catch (error) { 50 | next(error); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app-gateway/src/api/customers/CustomersController.ts: -------------------------------------------------------------------------------- 1 | import {NextFunction, Request, Response} from 'express'; 2 | import * as HttpStatus from 'http-status-codes'; 3 | import CustomersService from './CustomersService'; 4 | 5 | 6 | 7 | export default class CustomersController { 8 | 9 | public static async findAll(req: Request, res: Response, next: NextFunction): Promise { 10 | try { 11 | const response = await CustomersService.findAll(); 12 | res.status(HttpStatus.OK).send(response); 13 | } catch (error) { 14 | next(error); 15 | } 16 | } 17 | 18 | public static async findById(req: Request, res: Response, next: NextFunction): Promise { 19 | try { 20 | const response = await CustomersService.findById(req.params.id); 21 | res.status(HttpStatus.OK).send(response); 22 | } catch (error) { 23 | next(error); 24 | } 25 | } 26 | 27 | public static async create(req: Request, res: Response, next: NextFunction): Promise { 28 | try { 29 | const response = await CustomersService.create(req.body); 30 | res.status(HttpStatus.CREATED).send(response); 31 | } catch (error) { 32 | next(error); 33 | } 34 | } 35 | 36 | public static async update(req: Request, res: Response, next: NextFunction): Promise { 37 | try { 38 | const response = await CustomersService.update(req.body); 39 | res.status(HttpStatus.CREATED).send(response); 40 | } catch (error) { 41 | next(error); 42 | } 43 | } 44 | 45 | public static async remove(req: Request, res: Response, next: NextFunction): Promise { 46 | try { 47 | const response = await CustomersService.remove(req.params.id); 48 | res.status(HttpStatus.OK).send(response); 49 | } catch (error) { 50 | next(error); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app-gateway/src/api/users/UsersController.ts: -------------------------------------------------------------------------------- 1 | import {NextFunction, Request, Response} from 'express'; 2 | import * as HttpStatus from 'http-status-codes'; 3 | import UsersService from './UsersService'; 4 | 5 | 6 | 7 | export default class UsersController { 8 | 9 | public static async findAll(req: Request, res: Response, next: NextFunction): Promise { 10 | try { 11 | const response = await UsersService.findAll(); 12 | res.status(HttpStatus.OK).send(response); 13 | } catch (error) { 14 | next(error); 15 | } 16 | } 17 | 18 | public static async findById(req: Request, res: Response, next: NextFunction): Promise { 19 | try { 20 | const response = await UsersService.findById(req.params.id); 21 | res.status(HttpStatus.OK).send(response); 22 | } catch (error) { 23 | next(error); 24 | } 25 | } 26 | 27 | public static async create(req: Request, res: Response, next: NextFunction): Promise { 28 | try { 29 | const response = await UsersService.create(req.body); 30 | res.status(HttpStatus.CREATED).send(response); 31 | } catch (error) { 32 | next(error); 33 | } 34 | } 35 | 36 | public static async update(req: Request, res: Response, next: NextFunction): Promise { 37 | try { 38 | const response = await UsersService.update(req.body); 39 | res.status(HttpStatus.CREATED).send(response); 40 | } catch (error) { 41 | next(error); 42 | } 43 | } 44 | 45 | public static async remove(req: Request, res: Response, next: NextFunction): Promise { 46 | try { 47 | const response = await UsersService.remove(req.params.id); 48 | res.status(HttpStatus.OK).send(response); 49 | } catch (error) { 50 | next(error); 51 | } 52 | } 53 | 54 | public static async login(req: Request, res: Response, next: NextFunction): Promise { 55 | try { 56 | const response = await UsersService.login(req.body); 57 | res.status(HttpStatus.OK).send(response); 58 | } catch (error) { 59 | next(error); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /docker/nginx/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | agent_conf_file="/etc/amplify-agent/agent.conf" 4 | agent_log_file="/var/log/amplify-agent/agent.log" 5 | nginx_status_conf="/etc/nginx/conf.d/stub_status.conf" 6 | api_key="" 7 | amplify_imagename=$HOSTNAME 8 | 9 | rm -rf /var/log/nginx/*.log 10 | 11 | envsubst '\${NGINX_SERVER_NAME}\${GRPC_SERVER_1}\${GRPC_SERVER_2}' \ 12 | < /etc/nginx/server.template.conf \ 13 | > /etc/nginx/sites-enabled/server_host.conf 14 | 15 | # Launch nginx 16 | echo "Starting nginx..." 17 | nginx -g "daemon off;" & 18 | 19 | nginx_pid=$! 20 | 21 | test -n "${API_KEY}" && \ 22 | api_key=${API_KEY} 23 | 24 | if [ -n "${api_key}" -o -n "${amplify_imagename}" ]; then 25 | echo "Amplify-agent updating ${agent_conf_file} ..." 26 | 27 | if [ ! -f "${agent_conf_file}" ]; then 28 | test -f "${agent_conf_file}.default" && \ 29 | cp -p "${agent_conf_file}.default" "${agent_conf_file}" || \ 30 | { echo "no ${agent_conf_file}.default found! exiting."; exit 1; } 31 | fi 32 | 33 | test -n "${api_key}" && \ 34 | echo "Amplify-agent using api_key = ${api_key}" && \ 35 | sh -c "sed -i.old -e 's/api_key.*$/api_key = $api_key/' \ 36 | ${agent_conf_file}" 37 | 38 | test -n "${amplify_imagename}" && \ 39 | echo "Amplify-agent using imagename = ${amplify_imagename}" && \ 40 | sh -c "sed -i.old -e 's/imagename.*$/imagename = $amplify_imagename/' \ 41 | ${agent_conf_file}" 42 | 43 | test -f "${agent_conf_file}" && \ 44 | chmod 644 ${agent_conf_file} && \ 45 | chown nginx ${agent_conf_file} > /dev/null 2>&1 46 | 47 | test -f "${nginx_status_conf}" && \ 48 | chmod 644 ${nginx_status_conf} && \ 49 | chown nginx ${nginx_status_conf} > /dev/null 2>&1 50 | fi 51 | 52 | if ! grep '^api_key.*=[ ]*[[:alnum:]].*' ${agent_conf_file} > /dev/null 2>&1; then 53 | echo "Amplify-agent no api_key found in ${agent_conf_file}! exiting." 54 | fi 55 | 56 | if [ -n "${api_key}" -o -n "${amplify_imagename}" ]; then 57 | echo "Starting amplify-agent..." 58 | service amplify-agent start > /dev/null 2>&1 < /dev/null 59 | 60 | if [ $? != 0 ]; then 61 | echo "Couldn't start the agent, please check ${agent_log_file}" 62 | exit 1 63 | fi 64 | fi 65 | 66 | echo "Nginx started" 67 | wait ${nginx_pid} 68 | 69 | echo "nginx master process has stopped, exiting." 70 | 71 | 72 | -------------------------------------------------------------------------------- /app-gateway/src/ConnectServer.ts: -------------------------------------------------------------------------------- 1 | import 'dotenv/config'; 2 | import * as http from 'http'; 3 | import App from './App'; 4 | 5 | 6 | class ConnectServer { 7 | protected port: number; 8 | 9 | constructor() { 10 | this.port = this.normalizePort(Number(process.env.PORT) || 3005); 11 | this.validateEnvironment(); 12 | } 13 | 14 | public startServer(): void { 15 | const server: http.Server = http.createServer(new App(this.port).app); 16 | server.listen(this.port); 17 | server.on('error', this.onError); 18 | server.on('listening', () => console.warn('Gateway gRPC server started')); 19 | } 20 | 21 | private normalizePort(value: number): number { 22 | if (isNaN(value)) return value; 23 | if (value >= 0) return value; 24 | throw new Error('PORT is undefined'); 25 | } 26 | 27 | private validateEnvironment(): void { 28 | if (!process.env.NODE_ENV) { 29 | console.error('NODE_ENV is undefined.'); 30 | process.exit(1); 31 | } 32 | 33 | if (process.env.NODE_ENV !== 'production') { 34 | this.processError(); 35 | } 36 | 37 | if (process.env.NODE_ENV === 'production' && typeof process.env.pm_id === 'undefined') { 38 | throw new Error('The application must be run through PM2 at the production stage'); 39 | } 40 | } 41 | 42 | private processError(): void { 43 | process.on('uncaughtException', error => { 44 | console.error(error); 45 | process.exit(1); 46 | }); 47 | process.on('unhandledRejection', error => { 48 | console.error(error); 49 | process.exit(1); 50 | }); 51 | } 52 | 53 | private onError(error: NodeJS.ErrnoException): void { 54 | if (error.syscall !== 'listen') throw error; 55 | const bind = typeof this.port === 'string' ? 'Pipe ' + this.port : 'Port ' + this.port; 56 | switch (error.code) { 57 | case 'EACCES': 58 | console.error(`${bind} requires elevated privileges`); 59 | break; 60 | case 'EADDRINUSE': 61 | console.error(`${bind} is already in use`); 62 | break; 63 | default: 64 | throw error; 65 | } 66 | process.exit(1); 67 | } 68 | } 69 | 70 | export default new ConnectServer(); -------------------------------------------------------------------------------- /app-orders/src/controllers/orders.controller.go: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import ( 4 | pb "../proto" 5 | "context" 6 | "google.golang.org/grpc" 7 | "strconv" 8 | ) 9 | 10 | type server struct{} 11 | 12 | func (s *server) GetAll(ctx context.Context, in *pb.Empty) (*pb.OrdersResponseList, error) { 13 | 14 | var ordersResponseList []*pb.OrdersResponse 15 | var ordersResponse pb.OrdersResponse 16 | 17 | ordersResponse.Id = "58d6e7ef-add5-41a7-b661-e2685b19hg7e" 18 | ordersResponse.CustomersId = "7a02caa6-b2c2-451e-8cf9-9e994593afe9" 19 | ordersResponse.DateOrders = "2020-05-26" 20 | 21 | var ordersItems pb.OrdersItemResponse 22 | ordersItems.Id = "58d6e7ef-add5-41a7-b661-e2654gfrc6ca" 23 | ordersItems.OrdersId = ordersResponse.Id 24 | ordersItems.ProductsId = "48d6e7ef-add5-41a7-b661-e2685b19c6ca" 25 | ordersItems.Price = 5 26 | ordersItems.Quantity = 2 27 | ordersItems.TotalItem = ordersItems.Price * float32(ordersItems.Quantity) 28 | 29 | ordersResponse.OrdersItemResponse = append(ordersResponse.OrdersItemResponse, &ordersItems) 30 | 31 | ordersResponse.TotalOrders = ordersItems.TotalItem 32 | 33 | ordersResponseList = append(ordersResponseList, &ordersResponse) 34 | 35 | return &pb.OrdersResponseList{ 36 | OrdersResponseList: ordersResponseList, 37 | }, nil 38 | } 39 | 40 | func (s *server) Insert(ctx context.Context, ordersRequest *pb.OrdersRequest) (*pb.OrdersResponse, error) { 41 | var ordersItemsList []*pb.OrdersItemResponse 42 | ordersId := "58d6e7ef-add5-41a7-b661-e2685b19hg7e" 43 | var totalOrders = 0.0 44 | for index, element := range ordersRequest.OrdersItemRequestList { 45 | var ordersItems pb.OrdersItemResponse 46 | ordersItems.Id = strconv.Itoa(index + 1) 47 | ordersItems.OrdersId = ordersId 48 | ordersItems.ProductsId = element.ProductsId 49 | ordersItems.Price = element.Price 50 | ordersItems.Quantity = element.Quantity 51 | ordersItems.TotalItem = element.Price * float32(element.Quantity) 52 | totalOrders = float64(float32(totalOrders) + ordersItems.TotalItem) 53 | ordersItemsList = append(ordersItemsList, &ordersItems) 54 | } 55 | 56 | return &pb.OrdersResponse{ 57 | Id: ordersId, 58 | CustomersId: ordersRequest.CustomersId, 59 | DateOrders: ordersRequest.DateOrders, 60 | OrdersItemResponse: ordersItemsList, 61 | TotalOrders: float32(totalOrders), 62 | }, nil 63 | } 64 | 65 | func OrdersController(s *grpc.Server) { 66 | pb.RegisterOrdersServer(s, &server{}) 67 | } 68 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | 3 | services: 4 | grpc-customers1: 5 | container_name: grpc-customers1 6 | build: 7 | context: . 8 | dockerfile: docker/nodejs/Dockerfile 9 | environment: 10 | PORT: 40051 11 | ports: 12 | - 40051:40051 13 | volumes: 14 | - ./app-customers:/opt/app 15 | entrypoint: ["entrypoint-microservices.sh"] 16 | 17 | grpc-customers2: 18 | container_name: grpc-customers2 19 | build: 20 | context: . 21 | dockerfile: docker/nodejs/Dockerfile 22 | environment: 23 | PORT: 50051 24 | ports: 25 | - 50051:50051 26 | volumes: 27 | - ./app-customers:/opt/app 28 | entrypoint: ["entrypoint-microservices.sh"] 29 | 30 | grpc-users: 31 | container_name: grpc-users 32 | build: 33 | context: . 34 | dockerfile: docker/nodejs/Dockerfile 35 | ports: 36 | - 50052:50052 37 | volumes: 38 | - ./app-users:/opt/app 39 | entrypoint: ["entrypoint-microservices.sh"] 40 | 41 | grpc-products: 42 | container_name: grpc-products 43 | build: 44 | context: . 45 | dockerfile: docker/python/Dockerfile 46 | ports: 47 | - 50053:50053 48 | volumes: 49 | - ./app-products:/opt/app 50 | entrypoint: ["entrypoint-server.sh"] 51 | 52 | grpc-orders: 53 | container_name: grpc-orders 54 | build: 55 | context: . 56 | dockerfile: docker/go/Dockerfile 57 | ports: 58 | - 50054:50054 59 | volumes: 60 | - ./app-orders:/opt/app 61 | entrypoint: ["entrypoint-server.sh"] 62 | 63 | nginx-grpc: 64 | container_name: nginx-grpc 65 | hostname: "${HOST_NAME}" 66 | build: 67 | context: . 68 | dockerfile: docker/nginx/Dockerfile 69 | ports: 70 | - 8085:80 71 | links: 72 | - grpc-customers1 73 | - grpc-customers2 74 | depends_on: 75 | - grpc-customers1 76 | - grpc-customers2 77 | volumes: 78 | - ./docker/nginx/logs/nginx:/var/log/nginx 79 | 80 | api-gateway-grcp: 81 | container_name: api-gateway-grcp 82 | build: 83 | context: . 84 | dockerfile: docker/nodejs/Dockerfile 85 | ports: 86 | - 3005:3005 87 | links: 88 | - nginx-grpc 89 | - grpc-users 90 | - grpc-products 91 | - grpc-orders 92 | depends_on: 93 | - nginx-grpc 94 | - grpc-users 95 | - grpc-products 96 | - grpc-orders 97 | volumes: 98 | - ./app-gateway:/opt/app 99 | entrypoint: ["entrypoint-server.sh"] -------------------------------------------------------------------------------- /app-customers/src/repositories/CustomersRepository.ts: -------------------------------------------------------------------------------- 1 | import { 2 | CustomersInsertRequest, 3 | CustomersUpdateRequest, 4 | CustomersResponse, 5 | CustomersResponseList, 6 | Empty 7 | } from '../proto/customers/customers_pb'; 8 | import {v4 as uuidv4} from 'uuid'; 9 | 10 | 11 | export default class CustomersRepository { 12 | public static async findAll(): Promise { 13 | const customersResponseList: CustomersResponseList = new CustomersResponseList(); 14 | 15 | for (let i: number = 0; i <= 100; i++) { 16 | const customersResponse = new CustomersResponse(); 17 | customersResponse.setId(uuidv4()); 18 | customersResponse.setName(uuidv4()); 19 | customersResponse.setAge(Math.ceil(Math.random() * 10)); 20 | customersResponse.setAddress(uuidv4()); 21 | customersResponseList.addCustomersresponselist(customersResponse); 22 | } 23 | 24 | return Promise.resolve(customersResponseList); 25 | } 26 | 27 | public static async findById(id: string): Promise { 28 | const customersResponse = new CustomersResponse(); 29 | customersResponse.setId(id); 30 | customersResponse.setName('Hemicharly Thiago'); 31 | customersResponse.setAge(27); 32 | customersResponse.setAddress('Rua xxx'); 33 | 34 | return Promise.resolve(customersResponse); 35 | } 36 | 37 | public static async insert(request: CustomersInsertRequest): Promise { 38 | const customersResponse = new CustomersResponse(); 39 | customersResponse.setId(uuidv4()); 40 | customersResponse.setName(request.getName()); 41 | customersResponse.setAge(request.getAge()); 42 | customersResponse.setAddress(request.getAddress()); 43 | 44 | return Promise.resolve(customersResponse); 45 | } 46 | 47 | public static async update(request: CustomersUpdateRequest): Promise { 48 | const customersResponse = new CustomersResponse(); 49 | customersResponse.setId(request.getId()); 50 | customersResponse.setName(request.getName()); 51 | customersResponse.setAge(request.getAge()); 52 | customersResponse.setAddress(request.getAddress()); 53 | 54 | return Promise.resolve(customersResponse); 55 | } 56 | 57 | public static async removeById(id: string): Promise { 58 | console.log('Remove customer id: ', id); 59 | return Promise.resolve(new Empty()); 60 | } 61 | } -------------------------------------------------------------------------------- /app-users/src/repositories/UsersRepository.ts: -------------------------------------------------------------------------------- 1 | import { 2 | UsersInsertRequest, 3 | UsersUpdateRequest, 4 | UsersResponse, 5 | UsersResponseList, 6 | Empty, 7 | UsersLoginRequest, 8 | } from '../proto/users/users_pb'; 9 | import {v4 as uuidv4} from 'uuid'; 10 | 11 | 12 | export default class UsersRepository { 13 | public static async findAll(): Promise { 14 | const usersResponseList: UsersResponseList = new UsersResponseList(); 15 | 16 | for (let i: number = 0; i <= 100; i++) { 17 | const usersResponse = new UsersResponse(); 18 | usersResponse.setId(uuidv4()); 19 | usersResponse.setUsername(uuidv4()); 20 | usersResponse.setEmail(uuidv4()); 21 | usersResponseList.addUsersresponselist(usersResponse); 22 | } 23 | 24 | return Promise.resolve(usersResponseList); 25 | } 26 | 27 | public static async findById(id: string): Promise { 28 | 29 | const usersResponse = new UsersResponse(); 30 | usersResponse.setId(id); 31 | usersResponse.setUsername('teste'); 32 | usersResponse.setEmail('teste@gmail.com'); 33 | 34 | return Promise.resolve(usersResponse); 35 | } 36 | 37 | public static async insert(request: UsersInsertRequest): Promise { 38 | const usersResponse = new UsersResponse(); 39 | usersResponse.setId(uuidv4()); 40 | usersResponse.setUsername(request.getUsername()); 41 | usersResponse.setEmail(request.getEmail()); 42 | 43 | return Promise.resolve(usersResponse); 44 | } 45 | 46 | public static async update(request: UsersUpdateRequest): Promise { 47 | const usersResponse = new UsersResponse(); 48 | usersResponse.setId(request.getId()); 49 | usersResponse.setUsername(request.getUsername()); 50 | usersResponse.setEmail(request.getEmail()); 51 | 52 | return Promise.resolve(usersResponse); 53 | } 54 | 55 | public static async removeById(id: string): Promise { 56 | console.log('Remove user id: ', id); 57 | return Promise.resolve(new Empty()); 58 | } 59 | 60 | public static async login(request: UsersLoginRequest): Promise { 61 | const usersLoginResponse = new UsersResponse() 62 | usersLoginResponse.setId(uuidv4()); 63 | usersLoginResponse.setUsername(request.getUsername()); 64 | usersLoginResponse.setEmail(uuidv4()); 65 | 66 | return Promise.resolve(usersLoginResponse); 67 | } 68 | } -------------------------------------------------------------------------------- /app-customers/src/controllers/CustomersController.ts: -------------------------------------------------------------------------------- 1 | import * as grpc from 'grpc'; 2 | 3 | import {CustomersService, ICustomersServer} from '../proto/customers/customers_grpc_pb'; 4 | import { 5 | CustomersInsertRequest, 6 | CustomersUpdateRequest, 7 | CustomersRequestId, 8 | CustomersResponse, 9 | CustomersResponseList, 10 | Empty 11 | } from '../proto/customers/customers_pb'; 12 | import CustomersRepository from '../repositories/CustomersRepository'; 13 | 14 | 15 | class CustomersServer implements ICustomersServer { 16 | 17 | getAll = async (call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise => { 18 | try { 19 | const response: CustomersResponseList = await CustomersRepository.findAll(); 20 | callback(null, response); 21 | } catch (e) { 22 | callback(e, null); 23 | } 24 | }; 25 | 26 | get = async (call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise => { 27 | try { 28 | const response: CustomersResponse = await CustomersRepository.findById(call.request.getId()); 29 | callback(null, response); 30 | } catch (e) { 31 | callback(e, null); 32 | } 33 | }; 34 | 35 | insert = async (call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise => { 36 | try { 37 | const response: CustomersResponse = await CustomersRepository.insert(call.request); 38 | callback(null, response); 39 | } catch (e) { 40 | callback(e, null); 41 | } 42 | }; 43 | 44 | update = async (call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise => { 45 | try { 46 | const response: CustomersResponse = await CustomersRepository.update(call.request); 47 | callback(null, response); 48 | } catch (e) { 49 | callback(e, null); 50 | } 51 | }; 52 | 53 | remove = async (call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise => { 54 | try { 55 | const response: Empty = await CustomersRepository.removeById(call.request.getId()); 56 | callback(null, response); 57 | } catch (e) { 58 | callback(e, null); 59 | } 60 | }; 61 | } 62 | 63 | export default { 64 | service: CustomersService, 65 | server: new CustomersServer() 66 | }; 67 | -------------------------------------------------------------------------------- /app-users/src/controllers/UsersController.ts: -------------------------------------------------------------------------------- 1 | import * as grpc from 'grpc'; 2 | 3 | import {UsersService, IUsersServer} from '../proto/users/users_grpc_pb'; 4 | import { 5 | UsersInsertRequest, 6 | UsersUpdateRequest, 7 | UsersRequestId, 8 | UsersResponse, 9 | UsersResponseList, 10 | Empty, 11 | UsersLoginRequest 12 | } from '../proto/users/users_pb'; 13 | import UsersRepository from '../repositories/UsersRepository'; 14 | 15 | 16 | class UsersServer implements IUsersServer { 17 | 18 | getAll = async (call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise => { 19 | try { 20 | const response: UsersResponseList = await UsersRepository.findAll(); 21 | callback(null, response); 22 | } catch (e) { 23 | callback(e, null); 24 | } 25 | }; 26 | 27 | get = async (call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise => { 28 | try { 29 | const response: UsersResponse = await UsersRepository.findById(call.request.getId()); 30 | callback(null, response); 31 | } catch (e) { 32 | callback(e, null); 33 | } 34 | }; 35 | 36 | insert = async (call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise => { 37 | try { 38 | const response: UsersResponse = await UsersRepository.insert(call.request); 39 | callback(null, response); 40 | } catch (e) { 41 | callback(e, null); 42 | } 43 | }; 44 | 45 | update = async (call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise => { 46 | try { 47 | const response: UsersResponse = await UsersRepository.update(call.request); 48 | callback(null, response); 49 | } catch (e) { 50 | callback(e, null); 51 | } 52 | }; 53 | 54 | remove = async (call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise => { 55 | try { 56 | const response: Empty = await UsersRepository.removeById(call.request.getId()); 57 | callback(null, response); 58 | } catch (e) { 59 | callback(e, null); 60 | } 61 | }; 62 | 63 | login = async (call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise => { 64 | try { 65 | const response: UsersResponse = await UsersRepository.login(call.request); 66 | callback(null, response); 67 | } catch (e) { 68 | callback(e, null); 69 | } 70 | }; 71 | } 72 | 73 | 74 | export default { 75 | service: UsersService, 76 | server: new UsersServer() 77 | }; 78 | -------------------------------------------------------------------------------- /app-gateway/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "error", 3 | "extends": [ 4 | "tslint:recommended", 5 | "tslint-sonarts", 6 | "tslint-config-standard", 7 | "tslint-config-prettier" 8 | ], 9 | "rules": { 10 | "class-name": true, 11 | "no-console": false, 12 | "ordered-imports": true, 13 | "interface-name": false, 14 | "object-literal-sort-keys": false, 15 | "triple-equals": true, 16 | "radix": true, 17 | "max-classes-per-file": true, 18 | "file-name-casing": [true, "pascal-case"], 19 | "variable-name": { 20 | "options": [ 21 | "check-format", 22 | "allow-leading-underscore", 23 | "allow-pascal-case", 24 | "allow-trailing-underscore", 25 | "require-const-for-all-caps", 26 | "ban-keywords" 27 | ] 28 | }, 29 | "no-shadowed-variable": false, 30 | "ban-types": true, 31 | "no-bitwise" : true, 32 | "prefer-for-of": true, 33 | "member-ordering": [ 34 | true, 35 | { 36 | "order": [ 37 | "protected-static-field", 38 | "protected-static-method", 39 | "protected-instance-field", 40 | "protected-constructor", 41 | "protected-instance-method", 42 | 43 | "public-constructor", 44 | "public-static-field", 45 | "public-static-method", 46 | "public-instance-field", 47 | "public-instance-method", 48 | 49 | "private-static-field", 50 | "private-static-method", 51 | "private-instance-field", 52 | "private-constructor", 53 | "private-instance-method" 54 | ] 55 | } 56 | ], 57 | "no-duplicate-variable": true, 58 | "no-duplicate-imports": true, 59 | "await-promise": true, 60 | "promise-function-async": true, 61 | "unnecessary-else": true, 62 | "import-spacing": true, 63 | "quotemark": [true, "single", "jsx-double"], 64 | "no-duplicate-string": false, 65 | "no-identical-functions": true, 66 | "no-unconditional-jump": true, 67 | "no-big-function": true, 68 | "prefer-immediate-return": true, 69 | "no-invalid-await": true, 70 | "arguments-order": true, 71 | "mccabe-complexity": true, 72 | "cognitive-complexity": true, 73 | "consecutive-overloads": true, 74 | "use-primitive-type": true, 75 | "no-dead-store": true, 76 | "max-union-size": true, 77 | "no-gratuitous-expressions": true, 78 | "no-invariant-return": true, 79 | "no-undefined-argument": true 80 | }, 81 | "linterOptions": { 82 | "exclude": [ 83 | "**/*.js" 84 | ] 85 | } 86 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## API Gateway and gRPC microservices 2 | 3 | API Gateway with nodejs and microservices in gRPC with nodejs, python and golang. Examples for study purposes. 4 | 5 |

6 | 7 |

8 | 9 | #### 1. Requirements Installation 10 | 11 | * Install docker 12 | * Install docker-compose 13 | * Install Makefile 14 | 15 | #### 2. Steps to run this project 16 | 17 | ##### 2.1. Start project in mode development 18 | 19 | 20 | * Copy file `docker-compose.override.dist.yml` with name `docker-compose.override.yml` 21 | 22 | * Configure the environments: `API_KEY` is optional to monitor with amplify nginx 23 | 24 | * To create proto interfaces in the project gRPC microservices in nodejs and python, use the script `script/protoc.sh` 25 | 26 | * To start project using docker use the commands 27 | 28 | | COMMAND | DESCRIPTION | 29 | | --- | --- | 30 | | make dev | Execute all application in mode development | 31 | | make dev-grpc-customers | Execute grpc-customers application in mode development | 32 | | make dev-grpc-users | Execute grpc-users application in mode development | 33 | | make dev-grpc-products | Execute grpc-products application in mode development | 34 | | make dev-grpc-orders | Execute grpc-orders application in mode development | 35 | | make dev-api-gateway-grcp | Execute api-gateway-grcp application in mode development | 36 | | make prod-api-gateway-grcp | Execute api-gateway-grcp application in mode production | 37 | | make lint-fix-api-gateway | Execute command `yarn lint:fix` in api gateway | 38 | | make protoc-grpc-customers | Execute command `yarn protoc` to app-customers | 39 | | make protoc-grpc-users | Execute command `yarn protoc` to app-users | 40 | | make protoc-grpc-products | Execute command `script/protoc.sh` to app-products | 41 | | make nginx-start HOST_NAME=NGINX-01 | Execute nginx-grpc application using hostname | 42 | 43 | 44 | 45 | 46 | 47 | * note: if start project nodejs in mode `production` change the script `docker/nodejs/entrypoint-server.sh` 48 | 49 | from `yarn dev` to ` yarn build && yarn start` 50 | 51 | 52 | ##### 2.2. Testing the API Gateway 53 | 54 | * Access api gateway in `http://localhost:3005` 55 | 56 | | METHOD | SERVICES | 57 | | --- | --- | 58 | | GET | /customers | 59 | | GET | /customers/12385 | 60 | | POST | /customers | 61 | | PUT | /customers | 62 | | DELETE | /customers/12385 | 63 | | GET | /users | 64 | | GET | /users/47 | 65 | | POST | /users | 66 | | PUT | /users | 67 | | DELETE | /users/6 | 68 | | POST | /users/login | 69 | | GET | /products | 70 | | GET | /products/3 | 71 | | POST | /products | 72 | | PUT | /products | 73 | | DELETE | /products/5 | 74 | | GET | /orders | 75 | | POST | /orders | 76 | 77 | 78 | ##### 2.3. Testing the gRPC Microservices using BloomRPC 79 | 80 | * To install BloomRPC access the [guide](https://github.com/uw-labs/bloomrpc) 81 | * Access Microservice Customers gRPC in `127.0.0.1:50051` 82 | * Access Microservice Users gRPC in `127.0.0.1:50052` 83 | * Access Microservice Products gRPC in `127.0.0.1:50053` 84 | * Access Microservice Orders gRPC in `127.0.0.1:50054` 85 | 86 | 87 | 88 | ##### 3. Reference 89 | 90 | * What is gRPC [guide](https://grpc.io/docs/guides/) 91 | * Nginx with gRPC [guide](https://www.nginx.com/blog/nginx-1-13-10-grpc/?utm_campaign=core&utm_medium=blog&utm_source=youtube&utm_content=grpc) 92 | * What is Amplify Nginx [guide](https://amplify.nginx.com/docs/) 93 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### Windows template 2 | # Windows thumbnail cache files 3 | Thumbs.db 4 | Thumbs.db:encryptable 5 | ehthumbs.db 6 | ehthumbs_vista.db 7 | 8 | # Dump file 9 | *.stackdump 10 | 11 | # Folder config file 12 | [Dd]esktop.ini 13 | 14 | # Recycle Bin used on file shares 15 | $RECYCLE.BIN/ 16 | 17 | # Windows Installer files 18 | *.cab 19 | *.msi 20 | *.msix 21 | *.msm 22 | *.msp 23 | 24 | # Windows shortcuts 25 | *.lnk 26 | 27 | ### Node template 28 | # Logs 29 | logs 30 | *.log 31 | npm-debug.log* 32 | yarn-debug.log* 33 | yarn-error.log* 34 | lerna-debug.log* 35 | 36 | # Diagnostic reports (https://nodejs.org/api/report.html) 37 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 38 | 39 | # Runtime data 40 | pids 41 | *.pid 42 | *.seed 43 | *.pid.lock 44 | 45 | # Directory for instrumented libs generated by jscoverage/JSCover 46 | lib-cov 47 | 48 | # Coverage directory used by tools like istanbul 49 | coverage 50 | *.lcov 51 | 52 | # nyc test coverage 53 | .nyc_output 54 | 55 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 56 | .grunt 57 | 58 | # Bower dependency directory (https://bower.io/) 59 | bower_components 60 | 61 | # node-waf configuration 62 | .lock-wscript 63 | 64 | # Compiled binary addons (https://nodejs.org/api/addons.html) 65 | build/Release 66 | 67 | # Dependency directories 68 | node_modules/ 69 | jspm_packages/ 70 | 71 | # TypeScript v1 declaration files 72 | typings/ 73 | 74 | # TypeScript cache 75 | *.tsbuildinfo 76 | 77 | # Optional npm cache directory 78 | .npm 79 | 80 | # Optional eslint cache 81 | .eslintcache 82 | 83 | # Optional REPL history 84 | .node_repl_history 85 | 86 | # Output of 'npm pack' 87 | *.tgz 88 | 89 | # Yarn Integrity file 90 | .yarn-integrity 91 | 92 | # dotenv environment variables file 93 | app-users/.env 94 | .env.test 95 | 96 | # parcel-bundler cache (https://parceljs.org/) 97 | .cache 98 | 99 | # next.js build output 100 | .next 101 | 102 | # nuxt.js build output 103 | .nuxt 104 | 105 | # vuepress build output 106 | .vuepress/dist 107 | 108 | # Serverless directories 109 | .serverless/ 110 | 111 | # FuseBox cache 112 | .fusebox/ 113 | 114 | # DynamoDB Local files 115 | .dynamodb/ 116 | 117 | ### macOS template 118 | # General 119 | .DS_Store 120 | .AppleDouble 121 | .LSOverride 122 | 123 | # Icon must end with two \r 124 | Icon 125 | 126 | # Thumbnails 127 | ._* 128 | 129 | # Files that might appear in the root of a volume 130 | .DocumentRevisions-V100 131 | .fseventsd 132 | .Spotlight-V100 133 | .TemporaryItems 134 | .Trashes 135 | .VolumeIcon.icns 136 | .com.apple.timemachine.donotpresent 137 | 138 | # Directories potentially created on remote AFP share 139 | .AppleDB 140 | .AppleDesktop 141 | Network Trash Folder 142 | Temporary Items 143 | .apdisk 144 | 145 | ### JetBrains template 146 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 147 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 148 | 149 | # User-specific stuff 150 | .idea/**/workspace.xml 151 | .idea/**/tasks.xml 152 | .idea/**/usage.statistics.xml 153 | .idea/**/dictionaries 154 | .idea/**/shelf 155 | 156 | # Generated files 157 | .idea/**/contentModel.xml 158 | 159 | # Sensitive or high-churn files 160 | .idea/**/dataSources/ 161 | .idea/**/dataSources.ids 162 | .idea/**/dataSources.local.xml 163 | .idea/**/sqlDataSources.xml 164 | .idea/**/dynamic.xml 165 | .idea/**/uiDesigner.xml 166 | .idea/**/dbnavigator.xml 167 | 168 | # Gradle 169 | .idea/**/gradle.xml 170 | .idea/**/libraries 171 | 172 | # Gradle and Maven with auto-import 173 | # When using Gradle or Maven with auto-import, you should exclude module files, 174 | # since they will be recreated, and may cause churn. Uncomment if using 175 | # auto-import. 176 | # .idea/modules.xml 177 | # .idea/*.iml 178 | # .idea/modules 179 | # *.iml 180 | # *.ipr 181 | 182 | # CMake 183 | cmake-build-*/ 184 | 185 | # Mongo Explorer plugin 186 | .idea/**/mongoSettings.xml 187 | 188 | # File-based project format 189 | *.iws 190 | 191 | # IntelliJ 192 | out/ 193 | 194 | # mpeltonen/sbt-idea plugin 195 | .idea_modules/ 196 | 197 | # JIRA plugin 198 | atlassian-ide-plugin.xml 199 | 200 | # Cursive Clojure plugin 201 | .idea/replstate.xml 202 | 203 | # Crashlytics plugin (for Android Studio and IntelliJ) 204 | com_crashlytics_export_strings.xml 205 | crashlytics.properties 206 | crashlytics-build.properties 207 | fabric.properties 208 | 209 | # Editor-based Rest Client 210 | .idea/httpRequests 211 | 212 | # Android studio 3.1+ serialized cache file 213 | .idea/caches/build_file_checksums.ser 214 | 215 | .idea 216 | /dist 217 | /docker-compose.override.yml 218 | 219 | 220 | docker/nginx/logs 221 | !docker/nginx/logs/.gitkeep 222 | 223 | app-orders/src/proto/*.pb.go 224 | 225 | /app-gateway/logs 226 | /app-gateway/build 227 | -------------------------------------------------------------------------------- /app-customers/src/proto/customers/customers_grpc_pb.js: -------------------------------------------------------------------------------- 1 | // GENERATED CODE -- DO NOT EDIT! 2 | 3 | 'use strict'; 4 | var grpc = require('grpc'); 5 | var customers_pb = require('./customers_pb.js'); 6 | 7 | function serialize_CustomersInsertRequest(arg) { 8 | if (!(arg instanceof customers_pb.CustomersInsertRequest)) { 9 | throw new Error('Expected argument of type CustomersInsertRequest'); 10 | } 11 | return Buffer.from(arg.serializeBinary()); 12 | } 13 | 14 | function deserialize_CustomersInsertRequest(buffer_arg) { 15 | return customers_pb.CustomersInsertRequest.deserializeBinary(new Uint8Array(buffer_arg)); 16 | } 17 | 18 | function serialize_CustomersRequestId(arg) { 19 | if (!(arg instanceof customers_pb.CustomersRequestId)) { 20 | throw new Error('Expected argument of type CustomersRequestId'); 21 | } 22 | return Buffer.from(arg.serializeBinary()); 23 | } 24 | 25 | function deserialize_CustomersRequestId(buffer_arg) { 26 | return customers_pb.CustomersRequestId.deserializeBinary(new Uint8Array(buffer_arg)); 27 | } 28 | 29 | function serialize_CustomersResponse(arg) { 30 | if (!(arg instanceof customers_pb.CustomersResponse)) { 31 | throw new Error('Expected argument of type CustomersResponse'); 32 | } 33 | return Buffer.from(arg.serializeBinary()); 34 | } 35 | 36 | function deserialize_CustomersResponse(buffer_arg) { 37 | return customers_pb.CustomersResponse.deserializeBinary(new Uint8Array(buffer_arg)); 38 | } 39 | 40 | function serialize_CustomersResponseList(arg) { 41 | if (!(arg instanceof customers_pb.CustomersResponseList)) { 42 | throw new Error('Expected argument of type CustomersResponseList'); 43 | } 44 | return Buffer.from(arg.serializeBinary()); 45 | } 46 | 47 | function deserialize_CustomersResponseList(buffer_arg) { 48 | return customers_pb.CustomersResponseList.deserializeBinary(new Uint8Array(buffer_arg)); 49 | } 50 | 51 | function serialize_CustomersUpdateRequest(arg) { 52 | if (!(arg instanceof customers_pb.CustomersUpdateRequest)) { 53 | throw new Error('Expected argument of type CustomersUpdateRequest'); 54 | } 55 | return Buffer.from(arg.serializeBinary()); 56 | } 57 | 58 | function deserialize_CustomersUpdateRequest(buffer_arg) { 59 | return customers_pb.CustomersUpdateRequest.deserializeBinary(new Uint8Array(buffer_arg)); 60 | } 61 | 62 | function serialize_Empty(arg) { 63 | if (!(arg instanceof customers_pb.Empty)) { 64 | throw new Error('Expected argument of type Empty'); 65 | } 66 | return Buffer.from(arg.serializeBinary()); 67 | } 68 | 69 | function deserialize_Empty(buffer_arg) { 70 | return customers_pb.Empty.deserializeBinary(new Uint8Array(buffer_arg)); 71 | } 72 | 73 | 74 | var CustomersService = exports.CustomersService = { 75 | getAll: { 76 | path: '/Customers/GetAll', 77 | requestStream: false, 78 | responseStream: false, 79 | requestType: customers_pb.Empty, 80 | responseType: customers_pb.CustomersResponseList, 81 | requestSerialize: serialize_Empty, 82 | requestDeserialize: deserialize_Empty, 83 | responseSerialize: serialize_CustomersResponseList, 84 | responseDeserialize: deserialize_CustomersResponseList, 85 | }, 86 | get: { 87 | path: '/Customers/Get', 88 | requestStream: false, 89 | responseStream: false, 90 | requestType: customers_pb.CustomersRequestId, 91 | responseType: customers_pb.CustomersResponse, 92 | requestSerialize: serialize_CustomersRequestId, 93 | requestDeserialize: deserialize_CustomersRequestId, 94 | responseSerialize: serialize_CustomersResponse, 95 | responseDeserialize: deserialize_CustomersResponse, 96 | }, 97 | insert: { 98 | path: '/Customers/Insert', 99 | requestStream: false, 100 | responseStream: false, 101 | requestType: customers_pb.CustomersInsertRequest, 102 | responseType: customers_pb.CustomersResponse, 103 | requestSerialize: serialize_CustomersInsertRequest, 104 | requestDeserialize: deserialize_CustomersInsertRequest, 105 | responseSerialize: serialize_CustomersResponse, 106 | responseDeserialize: deserialize_CustomersResponse, 107 | }, 108 | update: { 109 | path: '/Customers/Update', 110 | requestStream: false, 111 | responseStream: false, 112 | requestType: customers_pb.CustomersUpdateRequest, 113 | responseType: customers_pb.CustomersResponse, 114 | requestSerialize: serialize_CustomersUpdateRequest, 115 | requestDeserialize: deserialize_CustomersUpdateRequest, 116 | responseSerialize: serialize_CustomersResponse, 117 | responseDeserialize: deserialize_CustomersResponse, 118 | }, 119 | remove: { 120 | path: '/Customers/Remove', 121 | requestStream: false, 122 | responseStream: false, 123 | requestType: customers_pb.CustomersRequestId, 124 | responseType: customers_pb.Empty, 125 | requestSerialize: serialize_CustomersRequestId, 126 | requestDeserialize: deserialize_CustomersRequestId, 127 | responseSerialize: serialize_Empty, 128 | responseDeserialize: deserialize_Empty, 129 | }, 130 | }; 131 | 132 | exports.CustomersClient = grpc.makeGenericClientConstructor(CustomersService); 133 | -------------------------------------------------------------------------------- /app-users/src/proto/users/users_grpc_pb.js: -------------------------------------------------------------------------------- 1 | // GENERATED CODE -- DO NOT EDIT! 2 | 3 | 'use strict'; 4 | var grpc = require('grpc'); 5 | var users_pb = require('./users_pb.js'); 6 | 7 | function serialize_Empty(arg) { 8 | if (!(arg instanceof users_pb.Empty)) { 9 | throw new Error('Expected argument of type Empty'); 10 | } 11 | return Buffer.from(arg.serializeBinary()); 12 | } 13 | 14 | function deserialize_Empty(buffer_arg) { 15 | return users_pb.Empty.deserializeBinary(new Uint8Array(buffer_arg)); 16 | } 17 | 18 | function serialize_UsersInsertRequest(arg) { 19 | if (!(arg instanceof users_pb.UsersInsertRequest)) { 20 | throw new Error('Expected argument of type UsersInsertRequest'); 21 | } 22 | return Buffer.from(arg.serializeBinary()); 23 | } 24 | 25 | function deserialize_UsersInsertRequest(buffer_arg) { 26 | return users_pb.UsersInsertRequest.deserializeBinary(new Uint8Array(buffer_arg)); 27 | } 28 | 29 | function serialize_UsersLoginRequest(arg) { 30 | if (!(arg instanceof users_pb.UsersLoginRequest)) { 31 | throw new Error('Expected argument of type UsersLoginRequest'); 32 | } 33 | return Buffer.from(arg.serializeBinary()); 34 | } 35 | 36 | function deserialize_UsersLoginRequest(buffer_arg) { 37 | return users_pb.UsersLoginRequest.deserializeBinary(new Uint8Array(buffer_arg)); 38 | } 39 | 40 | function serialize_UsersRequestId(arg) { 41 | if (!(arg instanceof users_pb.UsersRequestId)) { 42 | throw new Error('Expected argument of type UsersRequestId'); 43 | } 44 | return Buffer.from(arg.serializeBinary()); 45 | } 46 | 47 | function deserialize_UsersRequestId(buffer_arg) { 48 | return users_pb.UsersRequestId.deserializeBinary(new Uint8Array(buffer_arg)); 49 | } 50 | 51 | function serialize_UsersResponse(arg) { 52 | if (!(arg instanceof users_pb.UsersResponse)) { 53 | throw new Error('Expected argument of type UsersResponse'); 54 | } 55 | return Buffer.from(arg.serializeBinary()); 56 | } 57 | 58 | function deserialize_UsersResponse(buffer_arg) { 59 | return users_pb.UsersResponse.deserializeBinary(new Uint8Array(buffer_arg)); 60 | } 61 | 62 | function serialize_UsersResponseList(arg) { 63 | if (!(arg instanceof users_pb.UsersResponseList)) { 64 | throw new Error('Expected argument of type UsersResponseList'); 65 | } 66 | return Buffer.from(arg.serializeBinary()); 67 | } 68 | 69 | function deserialize_UsersResponseList(buffer_arg) { 70 | return users_pb.UsersResponseList.deserializeBinary(new Uint8Array(buffer_arg)); 71 | } 72 | 73 | function serialize_UsersUpdateRequest(arg) { 74 | if (!(arg instanceof users_pb.UsersUpdateRequest)) { 75 | throw new Error('Expected argument of type UsersUpdateRequest'); 76 | } 77 | return Buffer.from(arg.serializeBinary()); 78 | } 79 | 80 | function deserialize_UsersUpdateRequest(buffer_arg) { 81 | return users_pb.UsersUpdateRequest.deserializeBinary(new Uint8Array(buffer_arg)); 82 | } 83 | 84 | 85 | var UsersService = exports.UsersService = { 86 | getAll: { 87 | path: '/Users/GetAll', 88 | requestStream: false, 89 | responseStream: false, 90 | requestType: users_pb.Empty, 91 | responseType: users_pb.UsersResponseList, 92 | requestSerialize: serialize_Empty, 93 | requestDeserialize: deserialize_Empty, 94 | responseSerialize: serialize_UsersResponseList, 95 | responseDeserialize: deserialize_UsersResponseList, 96 | }, 97 | get: { 98 | path: '/Users/Get', 99 | requestStream: false, 100 | responseStream: false, 101 | requestType: users_pb.UsersRequestId, 102 | responseType: users_pb.UsersResponse, 103 | requestSerialize: serialize_UsersRequestId, 104 | requestDeserialize: deserialize_UsersRequestId, 105 | responseSerialize: serialize_UsersResponse, 106 | responseDeserialize: deserialize_UsersResponse, 107 | }, 108 | insert: { 109 | path: '/Users/Insert', 110 | requestStream: false, 111 | responseStream: false, 112 | requestType: users_pb.UsersInsertRequest, 113 | responseType: users_pb.UsersResponse, 114 | requestSerialize: serialize_UsersInsertRequest, 115 | requestDeserialize: deserialize_UsersInsertRequest, 116 | responseSerialize: serialize_UsersResponse, 117 | responseDeserialize: deserialize_UsersResponse, 118 | }, 119 | update: { 120 | path: '/Users/Update', 121 | requestStream: false, 122 | responseStream: false, 123 | requestType: users_pb.UsersUpdateRequest, 124 | responseType: users_pb.UsersResponse, 125 | requestSerialize: serialize_UsersUpdateRequest, 126 | requestDeserialize: deserialize_UsersUpdateRequest, 127 | responseSerialize: serialize_UsersResponse, 128 | responseDeserialize: deserialize_UsersResponse, 129 | }, 130 | remove: { 131 | path: '/Users/Remove', 132 | requestStream: false, 133 | responseStream: false, 134 | requestType: users_pb.UsersRequestId, 135 | responseType: users_pb.Empty, 136 | requestSerialize: serialize_UsersRequestId, 137 | requestDeserialize: deserialize_UsersRequestId, 138 | responseSerialize: serialize_Empty, 139 | responseDeserialize: deserialize_Empty, 140 | }, 141 | login: { 142 | path: '/Users/Login', 143 | requestStream: false, 144 | responseStream: false, 145 | requestType: users_pb.UsersLoginRequest, 146 | responseType: users_pb.UsersResponse, 147 | requestSerialize: serialize_UsersLoginRequest, 148 | requestDeserialize: deserialize_UsersLoginRequest, 149 | responseSerialize: serialize_UsersResponse, 150 | responseDeserialize: deserialize_UsersResponse, 151 | }, 152 | }; 153 | 154 | exports.UsersClient = grpc.makeGenericClientConstructor(UsersService); 155 | -------------------------------------------------------------------------------- /app-customers/src/proto/customers/customers_pb.d.ts: -------------------------------------------------------------------------------- 1 | // package: 2 | // file: customers.proto 3 | 4 | /* tslint:disable */ 5 | /* eslint-disable */ 6 | 7 | import * as jspb from "google-protobuf"; 8 | 9 | export class Empty extends jspb.Message { 10 | 11 | serializeBinary(): Uint8Array; 12 | toObject(includeInstance?: boolean): Empty.AsObject; 13 | static toObject(includeInstance: boolean, msg: Empty): Empty.AsObject; 14 | static extensions: {[key: number]: jspb.ExtensionFieldInfo}; 15 | static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; 16 | static serializeBinaryToWriter(message: Empty, writer: jspb.BinaryWriter): void; 17 | static deserializeBinary(bytes: Uint8Array): Empty; 18 | static deserializeBinaryFromReader(message: Empty, reader: jspb.BinaryReader): Empty; 19 | } 20 | 21 | export namespace Empty { 22 | export type AsObject = { 23 | } 24 | } 25 | 26 | export class CustomersInsertRequest extends jspb.Message { 27 | getName(): string; 28 | setName(value: string): void; 29 | 30 | getAge(): number; 31 | setAge(value: number): void; 32 | 33 | getAddress(): string; 34 | setAddress(value: string): void; 35 | 36 | 37 | serializeBinary(): Uint8Array; 38 | toObject(includeInstance?: boolean): CustomersInsertRequest.AsObject; 39 | static toObject(includeInstance: boolean, msg: CustomersInsertRequest): CustomersInsertRequest.AsObject; 40 | static extensions: {[key: number]: jspb.ExtensionFieldInfo}; 41 | static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; 42 | static serializeBinaryToWriter(message: CustomersInsertRequest, writer: jspb.BinaryWriter): void; 43 | static deserializeBinary(bytes: Uint8Array): CustomersInsertRequest; 44 | static deserializeBinaryFromReader(message: CustomersInsertRequest, reader: jspb.BinaryReader): CustomersInsertRequest; 45 | } 46 | 47 | export namespace CustomersInsertRequest { 48 | export type AsObject = { 49 | name: string, 50 | age: number, 51 | address: string, 52 | } 53 | } 54 | 55 | export class CustomersUpdateRequest extends jspb.Message { 56 | getId(): string; 57 | setId(value: string): void; 58 | 59 | getName(): string; 60 | setName(value: string): void; 61 | 62 | getAge(): number; 63 | setAge(value: number): void; 64 | 65 | getAddress(): string; 66 | setAddress(value: string): void; 67 | 68 | 69 | serializeBinary(): Uint8Array; 70 | toObject(includeInstance?: boolean): CustomersUpdateRequest.AsObject; 71 | static toObject(includeInstance: boolean, msg: CustomersUpdateRequest): CustomersUpdateRequest.AsObject; 72 | static extensions: {[key: number]: jspb.ExtensionFieldInfo}; 73 | static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; 74 | static serializeBinaryToWriter(message: CustomersUpdateRequest, writer: jspb.BinaryWriter): void; 75 | static deserializeBinary(bytes: Uint8Array): CustomersUpdateRequest; 76 | static deserializeBinaryFromReader(message: CustomersUpdateRequest, reader: jspb.BinaryReader): CustomersUpdateRequest; 77 | } 78 | 79 | export namespace CustomersUpdateRequest { 80 | export type AsObject = { 81 | id: string, 82 | name: string, 83 | age: number, 84 | address: string, 85 | } 86 | } 87 | 88 | export class CustomersRequestId extends jspb.Message { 89 | getId(): string; 90 | setId(value: string): void; 91 | 92 | 93 | serializeBinary(): Uint8Array; 94 | toObject(includeInstance?: boolean): CustomersRequestId.AsObject; 95 | static toObject(includeInstance: boolean, msg: CustomersRequestId): CustomersRequestId.AsObject; 96 | static extensions: {[key: number]: jspb.ExtensionFieldInfo}; 97 | static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; 98 | static serializeBinaryToWriter(message: CustomersRequestId, writer: jspb.BinaryWriter): void; 99 | static deserializeBinary(bytes: Uint8Array): CustomersRequestId; 100 | static deserializeBinaryFromReader(message: CustomersRequestId, reader: jspb.BinaryReader): CustomersRequestId; 101 | } 102 | 103 | export namespace CustomersRequestId { 104 | export type AsObject = { 105 | id: string, 106 | } 107 | } 108 | 109 | export class CustomersResponse extends jspb.Message { 110 | getId(): string; 111 | setId(value: string): void; 112 | 113 | getName(): string; 114 | setName(value: string): void; 115 | 116 | getAge(): number; 117 | setAge(value: number): void; 118 | 119 | getAddress(): string; 120 | setAddress(value: string): void; 121 | 122 | 123 | serializeBinary(): Uint8Array; 124 | toObject(includeInstance?: boolean): CustomersResponse.AsObject; 125 | static toObject(includeInstance: boolean, msg: CustomersResponse): CustomersResponse.AsObject; 126 | static extensions: {[key: number]: jspb.ExtensionFieldInfo}; 127 | static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; 128 | static serializeBinaryToWriter(message: CustomersResponse, writer: jspb.BinaryWriter): void; 129 | static deserializeBinary(bytes: Uint8Array): CustomersResponse; 130 | static deserializeBinaryFromReader(message: CustomersResponse, reader: jspb.BinaryReader): CustomersResponse; 131 | } 132 | 133 | export namespace CustomersResponse { 134 | export type AsObject = { 135 | id: string, 136 | name: string, 137 | age: number, 138 | address: string, 139 | } 140 | } 141 | 142 | export class CustomersResponseList extends jspb.Message { 143 | clearCustomersresponselistList(): void; 144 | getCustomersresponselistList(): Array; 145 | setCustomersresponselistList(value: Array): void; 146 | addCustomersresponselist(value?: CustomersResponse, index?: number): CustomersResponse; 147 | 148 | 149 | serializeBinary(): Uint8Array; 150 | toObject(includeInstance?: boolean): CustomersResponseList.AsObject; 151 | static toObject(includeInstance: boolean, msg: CustomersResponseList): CustomersResponseList.AsObject; 152 | static extensions: {[key: number]: jspb.ExtensionFieldInfo}; 153 | static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; 154 | static serializeBinaryToWriter(message: CustomersResponseList, writer: jspb.BinaryWriter): void; 155 | static deserializeBinary(bytes: Uint8Array): CustomersResponseList; 156 | static deserializeBinaryFromReader(message: CustomersResponseList, reader: jspb.BinaryReader): CustomersResponseList; 157 | } 158 | 159 | export namespace CustomersResponseList { 160 | export type AsObject = { 161 | customersresponselistList: Array, 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /app-users/src/proto/users/users_pb.d.ts: -------------------------------------------------------------------------------- 1 | // package: 2 | // file: users.proto 3 | 4 | /* tslint:disable */ 5 | /* eslint-disable */ 6 | 7 | import * as jspb from "google-protobuf"; 8 | 9 | export class Empty extends jspb.Message { 10 | 11 | serializeBinary(): Uint8Array; 12 | toObject(includeInstance?: boolean): Empty.AsObject; 13 | static toObject(includeInstance: boolean, msg: Empty): Empty.AsObject; 14 | static extensions: {[key: number]: jspb.ExtensionFieldInfo}; 15 | static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; 16 | static serializeBinaryToWriter(message: Empty, writer: jspb.BinaryWriter): void; 17 | static deserializeBinary(bytes: Uint8Array): Empty; 18 | static deserializeBinaryFromReader(message: Empty, reader: jspb.BinaryReader): Empty; 19 | } 20 | 21 | export namespace Empty { 22 | export type AsObject = { 23 | } 24 | } 25 | 26 | export class UsersInsertRequest extends jspb.Message { 27 | getUsername(): string; 28 | setUsername(value: string): void; 29 | 30 | getPassword(): string; 31 | setPassword(value: string): void; 32 | 33 | getEmail(): string; 34 | setEmail(value: string): void; 35 | 36 | 37 | serializeBinary(): Uint8Array; 38 | toObject(includeInstance?: boolean): UsersInsertRequest.AsObject; 39 | static toObject(includeInstance: boolean, msg: UsersInsertRequest): UsersInsertRequest.AsObject; 40 | static extensions: {[key: number]: jspb.ExtensionFieldInfo}; 41 | static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; 42 | static serializeBinaryToWriter(message: UsersInsertRequest, writer: jspb.BinaryWriter): void; 43 | static deserializeBinary(bytes: Uint8Array): UsersInsertRequest; 44 | static deserializeBinaryFromReader(message: UsersInsertRequest, reader: jspb.BinaryReader): UsersInsertRequest; 45 | } 46 | 47 | export namespace UsersInsertRequest { 48 | export type AsObject = { 49 | username: string, 50 | password: string, 51 | email: string, 52 | } 53 | } 54 | 55 | export class UsersLoginRequest extends jspb.Message { 56 | getUsername(): string; 57 | setUsername(value: string): void; 58 | 59 | getPassword(): string; 60 | setPassword(value: string): void; 61 | 62 | 63 | serializeBinary(): Uint8Array; 64 | toObject(includeInstance?: boolean): UsersLoginRequest.AsObject; 65 | static toObject(includeInstance: boolean, msg: UsersLoginRequest): UsersLoginRequest.AsObject; 66 | static extensions: {[key: number]: jspb.ExtensionFieldInfo}; 67 | static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; 68 | static serializeBinaryToWriter(message: UsersLoginRequest, writer: jspb.BinaryWriter): void; 69 | static deserializeBinary(bytes: Uint8Array): UsersLoginRequest; 70 | static deserializeBinaryFromReader(message: UsersLoginRequest, reader: jspb.BinaryReader): UsersLoginRequest; 71 | } 72 | 73 | export namespace UsersLoginRequest { 74 | export type AsObject = { 75 | username: string, 76 | password: string, 77 | } 78 | } 79 | 80 | export class UsersUpdateRequest extends jspb.Message { 81 | getId(): string; 82 | setId(value: string): void; 83 | 84 | getUsername(): string; 85 | setUsername(value: string): void; 86 | 87 | getPassword(): string; 88 | setPassword(value: string): void; 89 | 90 | getEmail(): string; 91 | setEmail(value: string): void; 92 | 93 | 94 | serializeBinary(): Uint8Array; 95 | toObject(includeInstance?: boolean): UsersUpdateRequest.AsObject; 96 | static toObject(includeInstance: boolean, msg: UsersUpdateRequest): UsersUpdateRequest.AsObject; 97 | static extensions: {[key: number]: jspb.ExtensionFieldInfo}; 98 | static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; 99 | static serializeBinaryToWriter(message: UsersUpdateRequest, writer: jspb.BinaryWriter): void; 100 | static deserializeBinary(bytes: Uint8Array): UsersUpdateRequest; 101 | static deserializeBinaryFromReader(message: UsersUpdateRequest, reader: jspb.BinaryReader): UsersUpdateRequest; 102 | } 103 | 104 | export namespace UsersUpdateRequest { 105 | export type AsObject = { 106 | id: string, 107 | username: string, 108 | password: string, 109 | email: string, 110 | } 111 | } 112 | 113 | export class UsersRequestId extends jspb.Message { 114 | getId(): string; 115 | setId(value: string): void; 116 | 117 | 118 | serializeBinary(): Uint8Array; 119 | toObject(includeInstance?: boolean): UsersRequestId.AsObject; 120 | static toObject(includeInstance: boolean, msg: UsersRequestId): UsersRequestId.AsObject; 121 | static extensions: {[key: number]: jspb.ExtensionFieldInfo}; 122 | static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; 123 | static serializeBinaryToWriter(message: UsersRequestId, writer: jspb.BinaryWriter): void; 124 | static deserializeBinary(bytes: Uint8Array): UsersRequestId; 125 | static deserializeBinaryFromReader(message: UsersRequestId, reader: jspb.BinaryReader): UsersRequestId; 126 | } 127 | 128 | export namespace UsersRequestId { 129 | export type AsObject = { 130 | id: string, 131 | } 132 | } 133 | 134 | export class UsersResponse extends jspb.Message { 135 | getId(): string; 136 | setId(value: string): void; 137 | 138 | getUsername(): string; 139 | setUsername(value: string): void; 140 | 141 | getEmail(): string; 142 | setEmail(value: string): void; 143 | 144 | 145 | serializeBinary(): Uint8Array; 146 | toObject(includeInstance?: boolean): UsersResponse.AsObject; 147 | static toObject(includeInstance: boolean, msg: UsersResponse): UsersResponse.AsObject; 148 | static extensions: {[key: number]: jspb.ExtensionFieldInfo}; 149 | static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; 150 | static serializeBinaryToWriter(message: UsersResponse, writer: jspb.BinaryWriter): void; 151 | static deserializeBinary(bytes: Uint8Array): UsersResponse; 152 | static deserializeBinaryFromReader(message: UsersResponse, reader: jspb.BinaryReader): UsersResponse; 153 | } 154 | 155 | export namespace UsersResponse { 156 | export type AsObject = { 157 | id: string, 158 | username: string, 159 | email: string, 160 | } 161 | } 162 | 163 | export class UsersResponseList extends jspb.Message { 164 | clearUsersresponselistList(): void; 165 | getUsersresponselistList(): Array; 166 | setUsersresponselistList(value: Array): void; 167 | addUsersresponselist(value?: UsersResponse, index?: number): UsersResponse; 168 | 169 | 170 | serializeBinary(): Uint8Array; 171 | toObject(includeInstance?: boolean): UsersResponseList.AsObject; 172 | static toObject(includeInstance: boolean, msg: UsersResponseList): UsersResponseList.AsObject; 173 | static extensions: {[key: number]: jspb.ExtensionFieldInfo}; 174 | static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; 175 | static serializeBinaryToWriter(message: UsersResponseList, writer: jspb.BinaryWriter): void; 176 | static deserializeBinary(bytes: Uint8Array): UsersResponseList; 177 | static deserializeBinaryFromReader(message: UsersResponseList, reader: jspb.BinaryReader): UsersResponseList; 178 | } 179 | 180 | export namespace UsersResponseList { 181 | export type AsObject = { 182 | usersresponselistList: Array, 183 | } 184 | } 185 | -------------------------------------------------------------------------------- /app-products/src/proto/products/products_pb2_grpc.py: -------------------------------------------------------------------------------- 1 | # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! 2 | import grpc 3 | 4 | import products_pb2 as products_dot_products__pb2 5 | 6 | 7 | class ProductsStub(object): 8 | """Missing associated documentation comment in .proto file""" 9 | 10 | def __init__(self, channel): 11 | """Constructor. 12 | 13 | Args: 14 | channel: A grpc.Channel. 15 | """ 16 | self.GetAll = channel.unary_unary( 17 | '/Products/GetAll', 18 | request_serializer=products_dot_products__pb2.Empty.SerializeToString, 19 | response_deserializer=products_dot_products__pb2.ProductsResponseList.FromString, 20 | ) 21 | self.Get = channel.unary_unary( 22 | '/Products/Get', 23 | request_serializer=products_dot_products__pb2.ProductsRequestId.SerializeToString, 24 | response_deserializer=products_dot_products__pb2.ProductsResponse.FromString, 25 | ) 26 | self.Insert = channel.unary_unary( 27 | '/Products/Insert', 28 | request_serializer=products_dot_products__pb2.ProductsInsertRequest.SerializeToString, 29 | response_deserializer=products_dot_products__pb2.ProductsResponse.FromString, 30 | ) 31 | self.Update = channel.unary_unary( 32 | '/Products/Update', 33 | request_serializer=products_dot_products__pb2.ProductsUpdateRequest.SerializeToString, 34 | response_deserializer=products_dot_products__pb2.ProductsResponse.FromString, 35 | ) 36 | self.Remove = channel.unary_unary( 37 | '/Products/Remove', 38 | request_serializer=products_dot_products__pb2.ProductsRequestId.SerializeToString, 39 | response_deserializer=products_dot_products__pb2.Empty.FromString, 40 | ) 41 | 42 | 43 | class ProductsServicer(object): 44 | """Missing associated documentation comment in .proto file""" 45 | 46 | def GetAll(self, request, context): 47 | """Missing associated documentation comment in .proto file""" 48 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 49 | context.set_details('Method not implemented!') 50 | raise NotImplementedError('Method not implemented!') 51 | 52 | def Get(self, request, context): 53 | """Missing associated documentation comment in .proto file""" 54 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 55 | context.set_details('Method not implemented!') 56 | raise NotImplementedError('Method not implemented!') 57 | 58 | def Insert(self, request, context): 59 | """Missing associated documentation comment in .proto file""" 60 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 61 | context.set_details('Method not implemented!') 62 | raise NotImplementedError('Method not implemented!') 63 | 64 | def Update(self, request, context): 65 | """Missing associated documentation comment in .proto file""" 66 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 67 | context.set_details('Method not implemented!') 68 | raise NotImplementedError('Method not implemented!') 69 | 70 | def Remove(self, request, context): 71 | """Missing associated documentation comment in .proto file""" 72 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 73 | context.set_details('Method not implemented!') 74 | raise NotImplementedError('Method not implemented!') 75 | 76 | 77 | def add_ProductsServicer_to_server(servicer, server): 78 | rpc_method_handlers = { 79 | 'GetAll': grpc.unary_unary_rpc_method_handler( 80 | servicer.GetAll, 81 | request_deserializer=products_dot_products__pb2.Empty.FromString, 82 | response_serializer=products_dot_products__pb2.ProductsResponseList.SerializeToString, 83 | ), 84 | 'Get': grpc.unary_unary_rpc_method_handler( 85 | servicer.Get, 86 | request_deserializer=products_dot_products__pb2.ProductsRequestId.FromString, 87 | response_serializer=products_dot_products__pb2.ProductsResponse.SerializeToString, 88 | ), 89 | 'Insert': grpc.unary_unary_rpc_method_handler( 90 | servicer.Insert, 91 | request_deserializer=products_dot_products__pb2.ProductsInsertRequest.FromString, 92 | response_serializer=products_dot_products__pb2.ProductsResponse.SerializeToString, 93 | ), 94 | 'Update': grpc.unary_unary_rpc_method_handler( 95 | servicer.Update, 96 | request_deserializer=products_dot_products__pb2.ProductsUpdateRequest.FromString, 97 | response_serializer=products_dot_products__pb2.ProductsResponse.SerializeToString, 98 | ), 99 | 'Remove': grpc.unary_unary_rpc_method_handler( 100 | servicer.Remove, 101 | request_deserializer=products_dot_products__pb2.ProductsRequestId.FromString, 102 | response_serializer=products_dot_products__pb2.Empty.SerializeToString, 103 | ), 104 | } 105 | generic_handler = grpc.method_handlers_generic_handler( 106 | 'Products', rpc_method_handlers) 107 | server.add_generic_rpc_handlers((generic_handler,)) 108 | 109 | 110 | # This class is part of an EXPERIMENTAL API. 111 | class Products(object): 112 | """Missing associated documentation comment in .proto file""" 113 | 114 | @staticmethod 115 | def GetAll(request, 116 | target, 117 | options=(), 118 | channel_credentials=None, 119 | call_credentials=None, 120 | compression=None, 121 | wait_for_ready=None, 122 | timeout=None, 123 | metadata=None): 124 | return grpc.experimental.unary_unary(request, target, '/Products/GetAll', 125 | products_dot_products__pb2.Empty.SerializeToString, 126 | products_dot_products__pb2.ProductsResponseList.FromString, 127 | options, channel_credentials, 128 | call_credentials, compression, wait_for_ready, timeout, metadata) 129 | 130 | @staticmethod 131 | def Get(request, 132 | target, 133 | options=(), 134 | channel_credentials=None, 135 | call_credentials=None, 136 | compression=None, 137 | wait_for_ready=None, 138 | timeout=None, 139 | metadata=None): 140 | return grpc.experimental.unary_unary(request, target, '/Products/Get', 141 | products_dot_products__pb2.ProductsRequestId.SerializeToString, 142 | products_dot_products__pb2.ProductsResponse.FromString, 143 | options, channel_credentials, 144 | call_credentials, compression, wait_for_ready, timeout, metadata) 145 | 146 | @staticmethod 147 | def Insert(request, 148 | target, 149 | options=(), 150 | channel_credentials=None, 151 | call_credentials=None, 152 | compression=None, 153 | wait_for_ready=None, 154 | timeout=None, 155 | metadata=None): 156 | return grpc.experimental.unary_unary(request, target, '/Products/Insert', 157 | products_dot_products__pb2.ProductsInsertRequest.SerializeToString, 158 | products_dot_products__pb2.ProductsResponse.FromString, 159 | options, channel_credentials, 160 | call_credentials, compression, wait_for_ready, timeout, metadata) 161 | 162 | @staticmethod 163 | def Update(request, 164 | target, 165 | options=(), 166 | channel_credentials=None, 167 | call_credentials=None, 168 | compression=None, 169 | wait_for_ready=None, 170 | timeout=None, 171 | metadata=None): 172 | return grpc.experimental.unary_unary(request, target, '/Products/Update', 173 | products_dot_products__pb2.ProductsUpdateRequest.SerializeToString, 174 | products_dot_products__pb2.ProductsResponse.FromString, 175 | options, channel_credentials, 176 | call_credentials, compression, wait_for_ready, timeout, metadata) 177 | 178 | @staticmethod 179 | def Remove(request, 180 | target, 181 | options=(), 182 | channel_credentials=None, 183 | call_credentials=None, 184 | compression=None, 185 | wait_for_ready=None, 186 | timeout=None, 187 | metadata=None): 188 | return grpc.experimental.unary_unary(request, target, '/Products/Remove', 189 | products_dot_products__pb2.ProductsRequestId.SerializeToString, 190 | products_dot_products__pb2.Empty.FromString, 191 | options, channel_credentials, 192 | call_credentials, compression, wait_for_ready, timeout, metadata) 193 | -------------------------------------------------------------------------------- /app-customers/src/proto/customers/customers_grpc_pb.d.ts: -------------------------------------------------------------------------------- 1 | // package: 2 | // file: customers.proto 3 | 4 | /* tslint:disable */ 5 | /* eslint-disable */ 6 | 7 | import * as grpc from "grpc"; 8 | import * as customers_pb from "./customers_pb"; 9 | 10 | interface ICustomersService extends grpc.ServiceDefinition { 11 | getAll: ICustomersService_IGetAll; 12 | get: ICustomersService_IGet; 13 | insert: ICustomersService_IInsert; 14 | update: ICustomersService_IUpdate; 15 | remove: ICustomersService_IRemove; 16 | } 17 | 18 | interface ICustomersService_IGetAll extends grpc.MethodDefinition { 19 | path: string; // "/.Customers/GetAll" 20 | requestStream: boolean; // false 21 | responseStream: boolean; // false 22 | requestSerialize: grpc.serialize; 23 | requestDeserialize: grpc.deserialize; 24 | responseSerialize: grpc.serialize; 25 | responseDeserialize: grpc.deserialize; 26 | } 27 | interface ICustomersService_IGet extends grpc.MethodDefinition { 28 | path: string; // "/.Customers/Get" 29 | requestStream: boolean; // false 30 | responseStream: boolean; // false 31 | requestSerialize: grpc.serialize; 32 | requestDeserialize: grpc.deserialize; 33 | responseSerialize: grpc.serialize; 34 | responseDeserialize: grpc.deserialize; 35 | } 36 | interface ICustomersService_IInsert extends grpc.MethodDefinition { 37 | path: string; // "/.Customers/Insert" 38 | requestStream: boolean; // false 39 | responseStream: boolean; // false 40 | requestSerialize: grpc.serialize; 41 | requestDeserialize: grpc.deserialize; 42 | responseSerialize: grpc.serialize; 43 | responseDeserialize: grpc.deserialize; 44 | } 45 | interface ICustomersService_IUpdate extends grpc.MethodDefinition { 46 | path: string; // "/.Customers/Update" 47 | requestStream: boolean; // false 48 | responseStream: boolean; // false 49 | requestSerialize: grpc.serialize; 50 | requestDeserialize: grpc.deserialize; 51 | responseSerialize: grpc.serialize; 52 | responseDeserialize: grpc.deserialize; 53 | } 54 | interface ICustomersService_IRemove extends grpc.MethodDefinition { 55 | path: string; // "/.Customers/Remove" 56 | requestStream: boolean; // false 57 | responseStream: boolean; // false 58 | requestSerialize: grpc.serialize; 59 | requestDeserialize: grpc.deserialize; 60 | responseSerialize: grpc.serialize; 61 | responseDeserialize: grpc.deserialize; 62 | } 63 | 64 | export const CustomersService: ICustomersService; 65 | 66 | export interface ICustomersServer { 67 | getAll: grpc.handleUnaryCall; 68 | get: grpc.handleUnaryCall; 69 | insert: grpc.handleUnaryCall; 70 | update: grpc.handleUnaryCall; 71 | remove: grpc.handleUnaryCall; 72 | } 73 | 74 | export interface ICustomersClient { 75 | getAll(request: customers_pb.Empty, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponseList) => void): grpc.ClientUnaryCall; 76 | getAll(request: customers_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponseList) => void): grpc.ClientUnaryCall; 77 | getAll(request: customers_pb.Empty, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponseList) => void): grpc.ClientUnaryCall; 78 | get(request: customers_pb.CustomersRequestId, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 79 | get(request: customers_pb.CustomersRequestId, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 80 | get(request: customers_pb.CustomersRequestId, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 81 | insert(request: customers_pb.CustomersInsertRequest, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 82 | insert(request: customers_pb.CustomersInsertRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 83 | insert(request: customers_pb.CustomersInsertRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 84 | update(request: customers_pb.CustomersUpdateRequest, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 85 | update(request: customers_pb.CustomersUpdateRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 86 | update(request: customers_pb.CustomersUpdateRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 87 | remove(request: customers_pb.CustomersRequestId, callback: (error: grpc.ServiceError | null, response: customers_pb.Empty) => void): grpc.ClientUnaryCall; 88 | remove(request: customers_pb.CustomersRequestId, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: customers_pb.Empty) => void): grpc.ClientUnaryCall; 89 | remove(request: customers_pb.CustomersRequestId, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: customers_pb.Empty) => void): grpc.ClientUnaryCall; 90 | } 91 | 92 | export class CustomersClient extends grpc.Client implements ICustomersClient { 93 | constructor(address: string, credentials: grpc.ChannelCredentials, options?: object); 94 | public getAll(request: customers_pb.Empty, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponseList) => void): grpc.ClientUnaryCall; 95 | public getAll(request: customers_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponseList) => void): grpc.ClientUnaryCall; 96 | public getAll(request: customers_pb.Empty, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponseList) => void): grpc.ClientUnaryCall; 97 | public get(request: customers_pb.CustomersRequestId, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 98 | public get(request: customers_pb.CustomersRequestId, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 99 | public get(request: customers_pb.CustomersRequestId, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 100 | public insert(request: customers_pb.CustomersInsertRequest, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 101 | public insert(request: customers_pb.CustomersInsertRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 102 | public insert(request: customers_pb.CustomersInsertRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 103 | public update(request: customers_pb.CustomersUpdateRequest, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 104 | public update(request: customers_pb.CustomersUpdateRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 105 | public update(request: customers_pb.CustomersUpdateRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: customers_pb.CustomersResponse) => void): grpc.ClientUnaryCall; 106 | public remove(request: customers_pb.CustomersRequestId, callback: (error: grpc.ServiceError | null, response: customers_pb.Empty) => void): grpc.ClientUnaryCall; 107 | public remove(request: customers_pb.CustomersRequestId, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: customers_pb.Empty) => void): grpc.ClientUnaryCall; 108 | public remove(request: customers_pb.CustomersRequestId, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: customers_pb.Empty) => void): grpc.ClientUnaryCall; 109 | } 110 | -------------------------------------------------------------------------------- /app-users/src/proto/users/users_grpc_pb.d.ts: -------------------------------------------------------------------------------- 1 | // package: 2 | // file: users.proto 3 | 4 | /* tslint:disable */ 5 | /* eslint-disable */ 6 | 7 | import * as grpc from "grpc"; 8 | import * as users_pb from "./users_pb"; 9 | 10 | interface IUsersService extends grpc.ServiceDefinition { 11 | getAll: IUsersService_IGetAll; 12 | get: IUsersService_IGet; 13 | insert: IUsersService_IInsert; 14 | update: IUsersService_IUpdate; 15 | remove: IUsersService_IRemove; 16 | login: IUsersService_ILogin; 17 | } 18 | 19 | interface IUsersService_IGetAll extends grpc.MethodDefinition { 20 | path: string; // "/.Users/GetAll" 21 | requestStream: boolean; // false 22 | responseStream: boolean; // false 23 | requestSerialize: grpc.serialize; 24 | requestDeserialize: grpc.deserialize; 25 | responseSerialize: grpc.serialize; 26 | responseDeserialize: grpc.deserialize; 27 | } 28 | interface IUsersService_IGet extends grpc.MethodDefinition { 29 | path: string; // "/.Users/Get" 30 | requestStream: boolean; // false 31 | responseStream: boolean; // false 32 | requestSerialize: grpc.serialize; 33 | requestDeserialize: grpc.deserialize; 34 | responseSerialize: grpc.serialize; 35 | responseDeserialize: grpc.deserialize; 36 | } 37 | interface IUsersService_IInsert extends grpc.MethodDefinition { 38 | path: string; // "/.Users/Insert" 39 | requestStream: boolean; // false 40 | responseStream: boolean; // false 41 | requestSerialize: grpc.serialize; 42 | requestDeserialize: grpc.deserialize; 43 | responseSerialize: grpc.serialize; 44 | responseDeserialize: grpc.deserialize; 45 | } 46 | interface IUsersService_IUpdate extends grpc.MethodDefinition { 47 | path: string; // "/.Users/Update" 48 | requestStream: boolean; // false 49 | responseStream: boolean; // false 50 | requestSerialize: grpc.serialize; 51 | requestDeserialize: grpc.deserialize; 52 | responseSerialize: grpc.serialize; 53 | responseDeserialize: grpc.deserialize; 54 | } 55 | interface IUsersService_IRemove extends grpc.MethodDefinition { 56 | path: string; // "/.Users/Remove" 57 | requestStream: boolean; // false 58 | responseStream: boolean; // false 59 | requestSerialize: grpc.serialize; 60 | requestDeserialize: grpc.deserialize; 61 | responseSerialize: grpc.serialize; 62 | responseDeserialize: grpc.deserialize; 63 | } 64 | interface IUsersService_ILogin extends grpc.MethodDefinition { 65 | path: string; // "/.Users/Login" 66 | requestStream: boolean; // false 67 | responseStream: boolean; // false 68 | requestSerialize: grpc.serialize; 69 | requestDeserialize: grpc.deserialize; 70 | responseSerialize: grpc.serialize; 71 | responseDeserialize: grpc.deserialize; 72 | } 73 | 74 | export const UsersService: IUsersService; 75 | 76 | export interface IUsersServer { 77 | getAll: grpc.handleUnaryCall; 78 | get: grpc.handleUnaryCall; 79 | insert: grpc.handleUnaryCall; 80 | update: grpc.handleUnaryCall; 81 | remove: grpc.handleUnaryCall; 82 | login: grpc.handleUnaryCall; 83 | } 84 | 85 | export interface IUsersClient { 86 | getAll(request: users_pb.Empty, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponseList) => void): grpc.ClientUnaryCall; 87 | getAll(request: users_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponseList) => void): grpc.ClientUnaryCall; 88 | getAll(request: users_pb.Empty, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponseList) => void): grpc.ClientUnaryCall; 89 | get(request: users_pb.UsersRequestId, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 90 | get(request: users_pb.UsersRequestId, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 91 | get(request: users_pb.UsersRequestId, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 92 | insert(request: users_pb.UsersInsertRequest, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 93 | insert(request: users_pb.UsersInsertRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 94 | insert(request: users_pb.UsersInsertRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 95 | update(request: users_pb.UsersUpdateRequest, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 96 | update(request: users_pb.UsersUpdateRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 97 | update(request: users_pb.UsersUpdateRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 98 | remove(request: users_pb.UsersRequestId, callback: (error: grpc.ServiceError | null, response: users_pb.Empty) => void): grpc.ClientUnaryCall; 99 | remove(request: users_pb.UsersRequestId, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: users_pb.Empty) => void): grpc.ClientUnaryCall; 100 | remove(request: users_pb.UsersRequestId, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: users_pb.Empty) => void): grpc.ClientUnaryCall; 101 | login(request: users_pb.UsersLoginRequest, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 102 | login(request: users_pb.UsersLoginRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 103 | login(request: users_pb.UsersLoginRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 104 | } 105 | 106 | export class UsersClient extends grpc.Client implements IUsersClient { 107 | constructor(address: string, credentials: grpc.ChannelCredentials, options?: object); 108 | public getAll(request: users_pb.Empty, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponseList) => void): grpc.ClientUnaryCall; 109 | public getAll(request: users_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponseList) => void): grpc.ClientUnaryCall; 110 | public getAll(request: users_pb.Empty, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponseList) => void): grpc.ClientUnaryCall; 111 | public get(request: users_pb.UsersRequestId, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 112 | public get(request: users_pb.UsersRequestId, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 113 | public get(request: users_pb.UsersRequestId, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 114 | public insert(request: users_pb.UsersInsertRequest, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 115 | public insert(request: users_pb.UsersInsertRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 116 | public insert(request: users_pb.UsersInsertRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 117 | public update(request: users_pb.UsersUpdateRequest, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 118 | public update(request: users_pb.UsersUpdateRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 119 | public update(request: users_pb.UsersUpdateRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 120 | public remove(request: users_pb.UsersRequestId, callback: (error: grpc.ServiceError | null, response: users_pb.Empty) => void): grpc.ClientUnaryCall; 121 | public remove(request: users_pb.UsersRequestId, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: users_pb.Empty) => void): grpc.ClientUnaryCall; 122 | public remove(request: users_pb.UsersRequestId, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: users_pb.Empty) => void): grpc.ClientUnaryCall; 123 | public login(request: users_pb.UsersLoginRequest, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 124 | public login(request: users_pb.UsersLoginRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 125 | public login(request: users_pb.UsersLoginRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: users_pb.UsersResponse) => void): grpc.ClientUnaryCall; 126 | } 127 | -------------------------------------------------------------------------------- /app-products/src/proto/products/products_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: products/products.proto 4 | 5 | from google.protobuf import descriptor as _descriptor 6 | from google.protobuf import message as _message 7 | from google.protobuf import reflection as _reflection 8 | from google.protobuf import symbol_database as _symbol_database 9 | # @@protoc_insertion_point(imports) 10 | 11 | _sym_db = _symbol_database.Default() 12 | 13 | 14 | 15 | 16 | DESCRIPTOR = _descriptor.FileDescriptor( 17 | name='products/products.proto', 18 | package='', 19 | syntax='proto3', 20 | serialized_options=None, 21 | serialized_pb=b'\n\x17products/products.proto\"\x07\n\x05\x45mpty\"4\n\x15ProductsInsertRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05price\x18\x02 \x01(\x02\"@\n\x15ProductsUpdateRequest\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\r\n\x05price\x18\x03 \x01(\x02\"\x1f\n\x11ProductsRequestId\x12\n\n\x02id\x18\x01 \x01(\t\";\n\x10ProductsResponse\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\r\n\x05price\x18\x03 \x01(\x02\"G\n\x14ProductsResponseList\x12/\n\x14productsResponseList\x18\x01 \x03(\x0b\x32\x11.ProductsResponse2\xfb\x01\n\x08Products\x12)\n\x06GetAll\x12\x06.Empty\x1a\x15.ProductsResponseList\"\x00\x12.\n\x03Get\x12\x12.ProductsRequestId\x1a\x11.ProductsResponse\"\x00\x12\x35\n\x06Insert\x12\x16.ProductsInsertRequest\x1a\x11.ProductsResponse\"\x00\x12\x35\n\x06Update\x12\x16.ProductsUpdateRequest\x1a\x11.ProductsResponse\"\x00\x12&\n\x06Remove\x12\x12.ProductsRequestId\x1a\x06.Empty\"\x00\x62\x06proto3' 22 | ) 23 | 24 | 25 | 26 | 27 | _EMPTY = _descriptor.Descriptor( 28 | name='Empty', 29 | full_name='Empty', 30 | filename=None, 31 | file=DESCRIPTOR, 32 | containing_type=None, 33 | fields=[ 34 | ], 35 | extensions=[ 36 | ], 37 | nested_types=[], 38 | enum_types=[ 39 | ], 40 | serialized_options=None, 41 | is_extendable=False, 42 | syntax='proto3', 43 | extension_ranges=[], 44 | oneofs=[ 45 | ], 46 | serialized_start=27, 47 | serialized_end=34, 48 | ) 49 | 50 | 51 | _PRODUCTSINSERTREQUEST = _descriptor.Descriptor( 52 | name='ProductsInsertRequest', 53 | full_name='ProductsInsertRequest', 54 | filename=None, 55 | file=DESCRIPTOR, 56 | containing_type=None, 57 | fields=[ 58 | _descriptor.FieldDescriptor( 59 | name='name', full_name='ProductsInsertRequest.name', index=0, 60 | number=1, type=9, cpp_type=9, label=1, 61 | has_default_value=False, default_value=b"".decode('utf-8'), 62 | message_type=None, enum_type=None, containing_type=None, 63 | is_extension=False, extension_scope=None, 64 | serialized_options=None, file=DESCRIPTOR), 65 | _descriptor.FieldDescriptor( 66 | name='price', full_name='ProductsInsertRequest.price', index=1, 67 | number=2, type=2, cpp_type=6, label=1, 68 | has_default_value=False, default_value=float(0), 69 | message_type=None, enum_type=None, containing_type=None, 70 | is_extension=False, extension_scope=None, 71 | serialized_options=None, file=DESCRIPTOR), 72 | ], 73 | extensions=[ 74 | ], 75 | nested_types=[], 76 | enum_types=[ 77 | ], 78 | serialized_options=None, 79 | is_extendable=False, 80 | syntax='proto3', 81 | extension_ranges=[], 82 | oneofs=[ 83 | ], 84 | serialized_start=36, 85 | serialized_end=88, 86 | ) 87 | 88 | 89 | _PRODUCTSUPDATEREQUEST = _descriptor.Descriptor( 90 | name='ProductsUpdateRequest', 91 | full_name='ProductsUpdateRequest', 92 | filename=None, 93 | file=DESCRIPTOR, 94 | containing_type=None, 95 | fields=[ 96 | _descriptor.FieldDescriptor( 97 | name='id', full_name='ProductsUpdateRequest.id', index=0, 98 | number=1, type=9, cpp_type=9, label=1, 99 | has_default_value=False, default_value=b"".decode('utf-8'), 100 | message_type=None, enum_type=None, containing_type=None, 101 | is_extension=False, extension_scope=None, 102 | serialized_options=None, file=DESCRIPTOR), 103 | _descriptor.FieldDescriptor( 104 | name='name', full_name='ProductsUpdateRequest.name', index=1, 105 | number=2, type=9, cpp_type=9, label=1, 106 | has_default_value=False, default_value=b"".decode('utf-8'), 107 | message_type=None, enum_type=None, containing_type=None, 108 | is_extension=False, extension_scope=None, 109 | serialized_options=None, file=DESCRIPTOR), 110 | _descriptor.FieldDescriptor( 111 | name='price', full_name='ProductsUpdateRequest.price', index=2, 112 | number=3, type=2, cpp_type=6, label=1, 113 | has_default_value=False, default_value=float(0), 114 | message_type=None, enum_type=None, containing_type=None, 115 | is_extension=False, extension_scope=None, 116 | serialized_options=None, file=DESCRIPTOR), 117 | ], 118 | extensions=[ 119 | ], 120 | nested_types=[], 121 | enum_types=[ 122 | ], 123 | serialized_options=None, 124 | is_extendable=False, 125 | syntax='proto3', 126 | extension_ranges=[], 127 | oneofs=[ 128 | ], 129 | serialized_start=90, 130 | serialized_end=154, 131 | ) 132 | 133 | 134 | _PRODUCTSREQUESTID = _descriptor.Descriptor( 135 | name='ProductsRequestId', 136 | full_name='ProductsRequestId', 137 | filename=None, 138 | file=DESCRIPTOR, 139 | containing_type=None, 140 | fields=[ 141 | _descriptor.FieldDescriptor( 142 | name='id', full_name='ProductsRequestId.id', index=0, 143 | number=1, type=9, cpp_type=9, label=1, 144 | has_default_value=False, default_value=b"".decode('utf-8'), 145 | message_type=None, enum_type=None, containing_type=None, 146 | is_extension=False, extension_scope=None, 147 | serialized_options=None, file=DESCRIPTOR), 148 | ], 149 | extensions=[ 150 | ], 151 | nested_types=[], 152 | enum_types=[ 153 | ], 154 | serialized_options=None, 155 | is_extendable=False, 156 | syntax='proto3', 157 | extension_ranges=[], 158 | oneofs=[ 159 | ], 160 | serialized_start=156, 161 | serialized_end=187, 162 | ) 163 | 164 | 165 | _PRODUCTSRESPONSE = _descriptor.Descriptor( 166 | name='ProductsResponse', 167 | full_name='ProductsResponse', 168 | filename=None, 169 | file=DESCRIPTOR, 170 | containing_type=None, 171 | fields=[ 172 | _descriptor.FieldDescriptor( 173 | name='id', full_name='ProductsResponse.id', index=0, 174 | number=1, type=9, cpp_type=9, label=1, 175 | has_default_value=False, default_value=b"".decode('utf-8'), 176 | message_type=None, enum_type=None, containing_type=None, 177 | is_extension=False, extension_scope=None, 178 | serialized_options=None, file=DESCRIPTOR), 179 | _descriptor.FieldDescriptor( 180 | name='name', full_name='ProductsResponse.name', index=1, 181 | number=2, type=9, cpp_type=9, label=1, 182 | has_default_value=False, default_value=b"".decode('utf-8'), 183 | message_type=None, enum_type=None, containing_type=None, 184 | is_extension=False, extension_scope=None, 185 | serialized_options=None, file=DESCRIPTOR), 186 | _descriptor.FieldDescriptor( 187 | name='price', full_name='ProductsResponse.price', index=2, 188 | number=3, type=2, cpp_type=6, label=1, 189 | has_default_value=False, default_value=float(0), 190 | message_type=None, enum_type=None, containing_type=None, 191 | is_extension=False, extension_scope=None, 192 | serialized_options=None, file=DESCRIPTOR), 193 | ], 194 | extensions=[ 195 | ], 196 | nested_types=[], 197 | enum_types=[ 198 | ], 199 | serialized_options=None, 200 | is_extendable=False, 201 | syntax='proto3', 202 | extension_ranges=[], 203 | oneofs=[ 204 | ], 205 | serialized_start=189, 206 | serialized_end=248, 207 | ) 208 | 209 | 210 | _PRODUCTSRESPONSELIST = _descriptor.Descriptor( 211 | name='ProductsResponseList', 212 | full_name='ProductsResponseList', 213 | filename=None, 214 | file=DESCRIPTOR, 215 | containing_type=None, 216 | fields=[ 217 | _descriptor.FieldDescriptor( 218 | name='productsResponseList', full_name='ProductsResponseList.productsResponseList', index=0, 219 | number=1, type=11, cpp_type=10, label=3, 220 | has_default_value=False, default_value=[], 221 | message_type=None, enum_type=None, containing_type=None, 222 | is_extension=False, extension_scope=None, 223 | serialized_options=None, file=DESCRIPTOR), 224 | ], 225 | extensions=[ 226 | ], 227 | nested_types=[], 228 | enum_types=[ 229 | ], 230 | serialized_options=None, 231 | is_extendable=False, 232 | syntax='proto3', 233 | extension_ranges=[], 234 | oneofs=[ 235 | ], 236 | serialized_start=250, 237 | serialized_end=321, 238 | ) 239 | 240 | _PRODUCTSRESPONSELIST.fields_by_name['productsResponseList'].message_type = _PRODUCTSRESPONSE 241 | DESCRIPTOR.message_types_by_name['Empty'] = _EMPTY 242 | DESCRIPTOR.message_types_by_name['ProductsInsertRequest'] = _PRODUCTSINSERTREQUEST 243 | DESCRIPTOR.message_types_by_name['ProductsUpdateRequest'] = _PRODUCTSUPDATEREQUEST 244 | DESCRIPTOR.message_types_by_name['ProductsRequestId'] = _PRODUCTSREQUESTID 245 | DESCRIPTOR.message_types_by_name['ProductsResponse'] = _PRODUCTSRESPONSE 246 | DESCRIPTOR.message_types_by_name['ProductsResponseList'] = _PRODUCTSRESPONSELIST 247 | _sym_db.RegisterFileDescriptor(DESCRIPTOR) 248 | 249 | Empty = _reflection.GeneratedProtocolMessageType('Empty', (_message.Message,), { 250 | 'DESCRIPTOR' : _EMPTY, 251 | '__module__' : 'products.products_pb2' 252 | # @@protoc_insertion_point(class_scope:Empty) 253 | }) 254 | _sym_db.RegisterMessage(Empty) 255 | 256 | ProductsInsertRequest = _reflection.GeneratedProtocolMessageType('ProductsInsertRequest', (_message.Message,), { 257 | 'DESCRIPTOR' : _PRODUCTSINSERTREQUEST, 258 | '__module__' : 'products.products_pb2' 259 | # @@protoc_insertion_point(class_scope:ProductsInsertRequest) 260 | }) 261 | _sym_db.RegisterMessage(ProductsInsertRequest) 262 | 263 | ProductsUpdateRequest = _reflection.GeneratedProtocolMessageType('ProductsUpdateRequest', (_message.Message,), { 264 | 'DESCRIPTOR' : _PRODUCTSUPDATEREQUEST, 265 | '__module__' : 'products.products_pb2' 266 | # @@protoc_insertion_point(class_scope:ProductsUpdateRequest) 267 | }) 268 | _sym_db.RegisterMessage(ProductsUpdateRequest) 269 | 270 | ProductsRequestId = _reflection.GeneratedProtocolMessageType('ProductsRequestId', (_message.Message,), { 271 | 'DESCRIPTOR' : _PRODUCTSREQUESTID, 272 | '__module__' : 'products.products_pb2' 273 | # @@protoc_insertion_point(class_scope:ProductsRequestId) 274 | }) 275 | _sym_db.RegisterMessage(ProductsRequestId) 276 | 277 | ProductsResponse = _reflection.GeneratedProtocolMessageType('ProductsResponse', (_message.Message,), { 278 | 'DESCRIPTOR' : _PRODUCTSRESPONSE, 279 | '__module__' : 'products.products_pb2' 280 | # @@protoc_insertion_point(class_scope:ProductsResponse) 281 | }) 282 | _sym_db.RegisterMessage(ProductsResponse) 283 | 284 | ProductsResponseList = _reflection.GeneratedProtocolMessageType('ProductsResponseList', (_message.Message,), { 285 | 'DESCRIPTOR' : _PRODUCTSRESPONSELIST, 286 | '__module__' : 'products.products_pb2' 287 | # @@protoc_insertion_point(class_scope:ProductsResponseList) 288 | }) 289 | _sym_db.RegisterMessage(ProductsResponseList) 290 | 291 | 292 | 293 | _PRODUCTS = _descriptor.ServiceDescriptor( 294 | name='Products', 295 | full_name='Products', 296 | file=DESCRIPTOR, 297 | index=0, 298 | serialized_options=None, 299 | serialized_start=324, 300 | serialized_end=575, 301 | methods=[ 302 | _descriptor.MethodDescriptor( 303 | name='GetAll', 304 | full_name='Products.GetAll', 305 | index=0, 306 | containing_service=None, 307 | input_type=_EMPTY, 308 | output_type=_PRODUCTSRESPONSELIST, 309 | serialized_options=None, 310 | ), 311 | _descriptor.MethodDescriptor( 312 | name='Get', 313 | full_name='Products.Get', 314 | index=1, 315 | containing_service=None, 316 | input_type=_PRODUCTSREQUESTID, 317 | output_type=_PRODUCTSRESPONSE, 318 | serialized_options=None, 319 | ), 320 | _descriptor.MethodDescriptor( 321 | name='Insert', 322 | full_name='Products.Insert', 323 | index=2, 324 | containing_service=None, 325 | input_type=_PRODUCTSINSERTREQUEST, 326 | output_type=_PRODUCTSRESPONSE, 327 | serialized_options=None, 328 | ), 329 | _descriptor.MethodDescriptor( 330 | name='Update', 331 | full_name='Products.Update', 332 | index=3, 333 | containing_service=None, 334 | input_type=_PRODUCTSUPDATEREQUEST, 335 | output_type=_PRODUCTSRESPONSE, 336 | serialized_options=None, 337 | ), 338 | _descriptor.MethodDescriptor( 339 | name='Remove', 340 | full_name='Products.Remove', 341 | index=4, 342 | containing_service=None, 343 | input_type=_PRODUCTSREQUESTID, 344 | output_type=_EMPTY, 345 | serialized_options=None, 346 | ), 347 | ]) 348 | _sym_db.RegisterServiceDescriptor(_PRODUCTS) 349 | 350 | DESCRIPTOR.services_by_name['Products'] = _PRODUCTS 351 | 352 | # @@protoc_insertion_point(module_scope) 353 | -------------------------------------------------------------------------------- /app-customers/src/proto/customers/customers_pb.js: -------------------------------------------------------------------------------- 1 | // source: customers.proto 2 | /** 3 | * @fileoverview 4 | * @enhanceable 5 | * @suppress {messageConventions} JS Compiler reports an error if a variable or 6 | * field starts with 'MSG_' and isn't a translatable message. 7 | * @public 8 | */ 9 | // GENERATED CODE -- DO NOT EDIT! 10 | 11 | var jspb = require('google-protobuf'); 12 | var goog = jspb; 13 | var global = Function('return this')(); 14 | 15 | goog.exportSymbol('proto.CustomersInsertRequest', null, global); 16 | goog.exportSymbol('proto.CustomersRequestId', null, global); 17 | goog.exportSymbol('proto.CustomersResponse', null, global); 18 | goog.exportSymbol('proto.CustomersResponseList', null, global); 19 | goog.exportSymbol('proto.CustomersUpdateRequest', null, global); 20 | goog.exportSymbol('proto.Empty', null, global); 21 | /** 22 | * Generated by JsPbCodeGenerator. 23 | * @param {Array=} opt_data Optional initial data array, typically from a 24 | * server response, or constructed directly in Javascript. The array is used 25 | * in place and becomes part of the constructed object. It is not cloned. 26 | * If no data is provided, the constructed object will be empty, but still 27 | * valid. 28 | * @extends {jspb.Message} 29 | * @constructor 30 | */ 31 | proto.Empty = function(opt_data) { 32 | jspb.Message.initialize(this, opt_data, 0, -1, null, null); 33 | }; 34 | goog.inherits(proto.Empty, jspb.Message); 35 | if (goog.DEBUG && !COMPILED) { 36 | /** 37 | * @public 38 | * @override 39 | */ 40 | proto.Empty.displayName = 'proto.Empty'; 41 | } 42 | /** 43 | * Generated by JsPbCodeGenerator. 44 | * @param {Array=} opt_data Optional initial data array, typically from a 45 | * server response, or constructed directly in Javascript. The array is used 46 | * in place and becomes part of the constructed object. It is not cloned. 47 | * If no data is provided, the constructed object will be empty, but still 48 | * valid. 49 | * @extends {jspb.Message} 50 | * @constructor 51 | */ 52 | proto.CustomersInsertRequest = function(opt_data) { 53 | jspb.Message.initialize(this, opt_data, 0, -1, null, null); 54 | }; 55 | goog.inherits(proto.CustomersInsertRequest, jspb.Message); 56 | if (goog.DEBUG && !COMPILED) { 57 | /** 58 | * @public 59 | * @override 60 | */ 61 | proto.CustomersInsertRequest.displayName = 'proto.CustomersInsertRequest'; 62 | } 63 | /** 64 | * Generated by JsPbCodeGenerator. 65 | * @param {Array=} opt_data Optional initial data array, typically from a 66 | * server response, or constructed directly in Javascript. The array is used 67 | * in place and becomes part of the constructed object. It is not cloned. 68 | * If no data is provided, the constructed object will be empty, but still 69 | * valid. 70 | * @extends {jspb.Message} 71 | * @constructor 72 | */ 73 | proto.CustomersUpdateRequest = function(opt_data) { 74 | jspb.Message.initialize(this, opt_data, 0, -1, null, null); 75 | }; 76 | goog.inherits(proto.CustomersUpdateRequest, jspb.Message); 77 | if (goog.DEBUG && !COMPILED) { 78 | /** 79 | * @public 80 | * @override 81 | */ 82 | proto.CustomersUpdateRequest.displayName = 'proto.CustomersUpdateRequest'; 83 | } 84 | /** 85 | * Generated by JsPbCodeGenerator. 86 | * @param {Array=} opt_data Optional initial data array, typically from a 87 | * server response, or constructed directly in Javascript. The array is used 88 | * in place and becomes part of the constructed object. It is not cloned. 89 | * If no data is provided, the constructed object will be empty, but still 90 | * valid. 91 | * @extends {jspb.Message} 92 | * @constructor 93 | */ 94 | proto.CustomersRequestId = function(opt_data) { 95 | jspb.Message.initialize(this, opt_data, 0, -1, null, null); 96 | }; 97 | goog.inherits(proto.CustomersRequestId, jspb.Message); 98 | if (goog.DEBUG && !COMPILED) { 99 | /** 100 | * @public 101 | * @override 102 | */ 103 | proto.CustomersRequestId.displayName = 'proto.CustomersRequestId'; 104 | } 105 | /** 106 | * Generated by JsPbCodeGenerator. 107 | * @param {Array=} opt_data Optional initial data array, typically from a 108 | * server response, or constructed directly in Javascript. The array is used 109 | * in place and becomes part of the constructed object. It is not cloned. 110 | * If no data is provided, the constructed object will be empty, but still 111 | * valid. 112 | * @extends {jspb.Message} 113 | * @constructor 114 | */ 115 | proto.CustomersResponse = function(opt_data) { 116 | jspb.Message.initialize(this, opt_data, 0, -1, null, null); 117 | }; 118 | goog.inherits(proto.CustomersResponse, jspb.Message); 119 | if (goog.DEBUG && !COMPILED) { 120 | /** 121 | * @public 122 | * @override 123 | */ 124 | proto.CustomersResponse.displayName = 'proto.CustomersResponse'; 125 | } 126 | /** 127 | * Generated by JsPbCodeGenerator. 128 | * @param {Array=} opt_data Optional initial data array, typically from a 129 | * server response, or constructed directly in Javascript. The array is used 130 | * in place and becomes part of the constructed object. It is not cloned. 131 | * If no data is provided, the constructed object will be empty, but still 132 | * valid. 133 | * @extends {jspb.Message} 134 | * @constructor 135 | */ 136 | proto.CustomersResponseList = function(opt_data) { 137 | jspb.Message.initialize(this, opt_data, 0, -1, proto.CustomersResponseList.repeatedFields_, null); 138 | }; 139 | goog.inherits(proto.CustomersResponseList, jspb.Message); 140 | if (goog.DEBUG && !COMPILED) { 141 | /** 142 | * @public 143 | * @override 144 | */ 145 | proto.CustomersResponseList.displayName = 'proto.CustomersResponseList'; 146 | } 147 | 148 | 149 | 150 | if (jspb.Message.GENERATE_TO_OBJECT) { 151 | /** 152 | * Creates an object representation of this proto. 153 | * Field names that are reserved in JavaScript and will be renamed to pb_name. 154 | * Optional fields that are not set will be set to undefined. 155 | * To access a reserved field use, foo.pb_, eg, foo.pb_default. 156 | * For the list of reserved names please see: 157 | * net/proto2/compiler/js/internal/generator.cc#kKeyword. 158 | * @param {boolean=} opt_includeInstance Deprecated. whether to include the 159 | * JSPB instance for transitional soy proto support: 160 | * http://goto/soy-param-migration 161 | * @return {!Object} 162 | */ 163 | proto.Empty.prototype.toObject = function(opt_includeInstance) { 164 | return proto.Empty.toObject(opt_includeInstance, this); 165 | }; 166 | 167 | 168 | /** 169 | * Static version of the {@see toObject} method. 170 | * @param {boolean|undefined} includeInstance Deprecated. Whether to include 171 | * the JSPB instance for transitional soy proto support: 172 | * http://goto/soy-param-migration 173 | * @param {!proto.Empty} msg The msg instance to transform. 174 | * @return {!Object} 175 | * @suppress {unusedLocalVariables} f is only used for nested messages 176 | */ 177 | proto.Empty.toObject = function(includeInstance, msg) { 178 | var f, obj = { 179 | 180 | }; 181 | 182 | if (includeInstance) { 183 | obj.$jspbMessageInstance = msg; 184 | } 185 | return obj; 186 | }; 187 | } 188 | 189 | 190 | /** 191 | * Deserializes binary data (in protobuf wire format). 192 | * @param {jspb.ByteSource} bytes The bytes to deserialize. 193 | * @return {!proto.Empty} 194 | */ 195 | proto.Empty.deserializeBinary = function(bytes) { 196 | var reader = new jspb.BinaryReader(bytes); 197 | var msg = new proto.Empty; 198 | return proto.Empty.deserializeBinaryFromReader(msg, reader); 199 | }; 200 | 201 | 202 | /** 203 | * Deserializes binary data (in protobuf wire format) from the 204 | * given reader into the given message object. 205 | * @param {!proto.Empty} msg The message object to deserialize into. 206 | * @param {!jspb.BinaryReader} reader The BinaryReader to use. 207 | * @return {!proto.Empty} 208 | */ 209 | proto.Empty.deserializeBinaryFromReader = function(msg, reader) { 210 | while (reader.nextField()) { 211 | if (reader.isEndGroup()) { 212 | break; 213 | } 214 | var field = reader.getFieldNumber(); 215 | switch (field) { 216 | default: 217 | reader.skipField(); 218 | break; 219 | } 220 | } 221 | return msg; 222 | }; 223 | 224 | 225 | /** 226 | * Serializes the message to binary data (in protobuf wire format). 227 | * @return {!Uint8Array} 228 | */ 229 | proto.Empty.prototype.serializeBinary = function() { 230 | var writer = new jspb.BinaryWriter(); 231 | proto.Empty.serializeBinaryToWriter(this, writer); 232 | return writer.getResultBuffer(); 233 | }; 234 | 235 | 236 | /** 237 | * Serializes the given message to binary data (in protobuf wire 238 | * format), writing to the given BinaryWriter. 239 | * @param {!proto.Empty} message 240 | * @param {!jspb.BinaryWriter} writer 241 | * @suppress {unusedLocalVariables} f is only used for nested messages 242 | */ 243 | proto.Empty.serializeBinaryToWriter = function(message, writer) { 244 | var f = undefined; 245 | }; 246 | 247 | 248 | 249 | 250 | 251 | if (jspb.Message.GENERATE_TO_OBJECT) { 252 | /** 253 | * Creates an object representation of this proto. 254 | * Field names that are reserved in JavaScript and will be renamed to pb_name. 255 | * Optional fields that are not set will be set to undefined. 256 | * To access a reserved field use, foo.pb_, eg, foo.pb_default. 257 | * For the list of reserved names please see: 258 | * net/proto2/compiler/js/internal/generator.cc#kKeyword. 259 | * @param {boolean=} opt_includeInstance Deprecated. whether to include the 260 | * JSPB instance for transitional soy proto support: 261 | * http://goto/soy-param-migration 262 | * @return {!Object} 263 | */ 264 | proto.CustomersInsertRequest.prototype.toObject = function(opt_includeInstance) { 265 | return proto.CustomersInsertRequest.toObject(opt_includeInstance, this); 266 | }; 267 | 268 | 269 | /** 270 | * Static version of the {@see toObject} method. 271 | * @param {boolean|undefined} includeInstance Deprecated. Whether to include 272 | * the JSPB instance for transitional soy proto support: 273 | * http://goto/soy-param-migration 274 | * @param {!proto.CustomersInsertRequest} msg The msg instance to transform. 275 | * @return {!Object} 276 | * @suppress {unusedLocalVariables} f is only used for nested messages 277 | */ 278 | proto.CustomersInsertRequest.toObject = function(includeInstance, msg) { 279 | var f, obj = { 280 | name: jspb.Message.getFieldWithDefault(msg, 1, ""), 281 | age: jspb.Message.getFieldWithDefault(msg, 2, 0), 282 | address: jspb.Message.getFieldWithDefault(msg, 3, "") 283 | }; 284 | 285 | if (includeInstance) { 286 | obj.$jspbMessageInstance = msg; 287 | } 288 | return obj; 289 | }; 290 | } 291 | 292 | 293 | /** 294 | * Deserializes binary data (in protobuf wire format). 295 | * @param {jspb.ByteSource} bytes The bytes to deserialize. 296 | * @return {!proto.CustomersInsertRequest} 297 | */ 298 | proto.CustomersInsertRequest.deserializeBinary = function(bytes) { 299 | var reader = new jspb.BinaryReader(bytes); 300 | var msg = new proto.CustomersInsertRequest; 301 | return proto.CustomersInsertRequest.deserializeBinaryFromReader(msg, reader); 302 | }; 303 | 304 | 305 | /** 306 | * Deserializes binary data (in protobuf wire format) from the 307 | * given reader into the given message object. 308 | * @param {!proto.CustomersInsertRequest} msg The message object to deserialize into. 309 | * @param {!jspb.BinaryReader} reader The BinaryReader to use. 310 | * @return {!proto.CustomersInsertRequest} 311 | */ 312 | proto.CustomersInsertRequest.deserializeBinaryFromReader = function(msg, reader) { 313 | while (reader.nextField()) { 314 | if (reader.isEndGroup()) { 315 | break; 316 | } 317 | var field = reader.getFieldNumber(); 318 | switch (field) { 319 | case 1: 320 | var value = /** @type {string} */ (reader.readString()); 321 | msg.setName(value); 322 | break; 323 | case 2: 324 | var value = /** @type {number} */ (reader.readInt32()); 325 | msg.setAge(value); 326 | break; 327 | case 3: 328 | var value = /** @type {string} */ (reader.readString()); 329 | msg.setAddress(value); 330 | break; 331 | default: 332 | reader.skipField(); 333 | break; 334 | } 335 | } 336 | return msg; 337 | }; 338 | 339 | 340 | /** 341 | * Serializes the message to binary data (in protobuf wire format). 342 | * @return {!Uint8Array} 343 | */ 344 | proto.CustomersInsertRequest.prototype.serializeBinary = function() { 345 | var writer = new jspb.BinaryWriter(); 346 | proto.CustomersInsertRequest.serializeBinaryToWriter(this, writer); 347 | return writer.getResultBuffer(); 348 | }; 349 | 350 | 351 | /** 352 | * Serializes the given message to binary data (in protobuf wire 353 | * format), writing to the given BinaryWriter. 354 | * @param {!proto.CustomersInsertRequest} message 355 | * @param {!jspb.BinaryWriter} writer 356 | * @suppress {unusedLocalVariables} f is only used for nested messages 357 | */ 358 | proto.CustomersInsertRequest.serializeBinaryToWriter = function(message, writer) { 359 | var f = undefined; 360 | f = message.getName(); 361 | if (f.length > 0) { 362 | writer.writeString( 363 | 1, 364 | f 365 | ); 366 | } 367 | f = message.getAge(); 368 | if (f !== 0) { 369 | writer.writeInt32( 370 | 2, 371 | f 372 | ); 373 | } 374 | f = message.getAddress(); 375 | if (f.length > 0) { 376 | writer.writeString( 377 | 3, 378 | f 379 | ); 380 | } 381 | }; 382 | 383 | 384 | /** 385 | * optional string name = 1; 386 | * @return {string} 387 | */ 388 | proto.CustomersInsertRequest.prototype.getName = function() { 389 | return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); 390 | }; 391 | 392 | 393 | /** 394 | * @param {string} value 395 | * @return {!proto.CustomersInsertRequest} returns this 396 | */ 397 | proto.CustomersInsertRequest.prototype.setName = function(value) { 398 | return jspb.Message.setProto3StringField(this, 1, value); 399 | }; 400 | 401 | 402 | /** 403 | * optional int32 age = 2; 404 | * @return {number} 405 | */ 406 | proto.CustomersInsertRequest.prototype.getAge = function() { 407 | return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); 408 | }; 409 | 410 | 411 | /** 412 | * @param {number} value 413 | * @return {!proto.CustomersInsertRequest} returns this 414 | */ 415 | proto.CustomersInsertRequest.prototype.setAge = function(value) { 416 | return jspb.Message.setProto3IntField(this, 2, value); 417 | }; 418 | 419 | 420 | /** 421 | * optional string address = 3; 422 | * @return {string} 423 | */ 424 | proto.CustomersInsertRequest.prototype.getAddress = function() { 425 | return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); 426 | }; 427 | 428 | 429 | /** 430 | * @param {string} value 431 | * @return {!proto.CustomersInsertRequest} returns this 432 | */ 433 | proto.CustomersInsertRequest.prototype.setAddress = function(value) { 434 | return jspb.Message.setProto3StringField(this, 3, value); 435 | }; 436 | 437 | 438 | 439 | 440 | 441 | if (jspb.Message.GENERATE_TO_OBJECT) { 442 | /** 443 | * Creates an object representation of this proto. 444 | * Field names that are reserved in JavaScript and will be renamed to pb_name. 445 | * Optional fields that are not set will be set to undefined. 446 | * To access a reserved field use, foo.pb_, eg, foo.pb_default. 447 | * For the list of reserved names please see: 448 | * net/proto2/compiler/js/internal/generator.cc#kKeyword. 449 | * @param {boolean=} opt_includeInstance Deprecated. whether to include the 450 | * JSPB instance for transitional soy proto support: 451 | * http://goto/soy-param-migration 452 | * @return {!Object} 453 | */ 454 | proto.CustomersUpdateRequest.prototype.toObject = function(opt_includeInstance) { 455 | return proto.CustomersUpdateRequest.toObject(opt_includeInstance, this); 456 | }; 457 | 458 | 459 | /** 460 | * Static version of the {@see toObject} method. 461 | * @param {boolean|undefined} includeInstance Deprecated. Whether to include 462 | * the JSPB instance for transitional soy proto support: 463 | * http://goto/soy-param-migration 464 | * @param {!proto.CustomersUpdateRequest} msg The msg instance to transform. 465 | * @return {!Object} 466 | * @suppress {unusedLocalVariables} f is only used for nested messages 467 | */ 468 | proto.CustomersUpdateRequest.toObject = function(includeInstance, msg) { 469 | var f, obj = { 470 | id: jspb.Message.getFieldWithDefault(msg, 1, ""), 471 | name: jspb.Message.getFieldWithDefault(msg, 2, ""), 472 | age: jspb.Message.getFieldWithDefault(msg, 3, 0), 473 | address: jspb.Message.getFieldWithDefault(msg, 4, "") 474 | }; 475 | 476 | if (includeInstance) { 477 | obj.$jspbMessageInstance = msg; 478 | } 479 | return obj; 480 | }; 481 | } 482 | 483 | 484 | /** 485 | * Deserializes binary data (in protobuf wire format). 486 | * @param {jspb.ByteSource} bytes The bytes to deserialize. 487 | * @return {!proto.CustomersUpdateRequest} 488 | */ 489 | proto.CustomersUpdateRequest.deserializeBinary = function(bytes) { 490 | var reader = new jspb.BinaryReader(bytes); 491 | var msg = new proto.CustomersUpdateRequest; 492 | return proto.CustomersUpdateRequest.deserializeBinaryFromReader(msg, reader); 493 | }; 494 | 495 | 496 | /** 497 | * Deserializes binary data (in protobuf wire format) from the 498 | * given reader into the given message object. 499 | * @param {!proto.CustomersUpdateRequest} msg The message object to deserialize into. 500 | * @param {!jspb.BinaryReader} reader The BinaryReader to use. 501 | * @return {!proto.CustomersUpdateRequest} 502 | */ 503 | proto.CustomersUpdateRequest.deserializeBinaryFromReader = function(msg, reader) { 504 | while (reader.nextField()) { 505 | if (reader.isEndGroup()) { 506 | break; 507 | } 508 | var field = reader.getFieldNumber(); 509 | switch (field) { 510 | case 1: 511 | var value = /** @type {string} */ (reader.readString()); 512 | msg.setId(value); 513 | break; 514 | case 2: 515 | var value = /** @type {string} */ (reader.readString()); 516 | msg.setName(value); 517 | break; 518 | case 3: 519 | var value = /** @type {number} */ (reader.readInt32()); 520 | msg.setAge(value); 521 | break; 522 | case 4: 523 | var value = /** @type {string} */ (reader.readString()); 524 | msg.setAddress(value); 525 | break; 526 | default: 527 | reader.skipField(); 528 | break; 529 | } 530 | } 531 | return msg; 532 | }; 533 | 534 | 535 | /** 536 | * Serializes the message to binary data (in protobuf wire format). 537 | * @return {!Uint8Array} 538 | */ 539 | proto.CustomersUpdateRequest.prototype.serializeBinary = function() { 540 | var writer = new jspb.BinaryWriter(); 541 | proto.CustomersUpdateRequest.serializeBinaryToWriter(this, writer); 542 | return writer.getResultBuffer(); 543 | }; 544 | 545 | 546 | /** 547 | * Serializes the given message to binary data (in protobuf wire 548 | * format), writing to the given BinaryWriter. 549 | * @param {!proto.CustomersUpdateRequest} message 550 | * @param {!jspb.BinaryWriter} writer 551 | * @suppress {unusedLocalVariables} f is only used for nested messages 552 | */ 553 | proto.CustomersUpdateRequest.serializeBinaryToWriter = function(message, writer) { 554 | var f = undefined; 555 | f = message.getId(); 556 | if (f.length > 0) { 557 | writer.writeString( 558 | 1, 559 | f 560 | ); 561 | } 562 | f = message.getName(); 563 | if (f.length > 0) { 564 | writer.writeString( 565 | 2, 566 | f 567 | ); 568 | } 569 | f = message.getAge(); 570 | if (f !== 0) { 571 | writer.writeInt32( 572 | 3, 573 | f 574 | ); 575 | } 576 | f = message.getAddress(); 577 | if (f.length > 0) { 578 | writer.writeString( 579 | 4, 580 | f 581 | ); 582 | } 583 | }; 584 | 585 | 586 | /** 587 | * optional string id = 1; 588 | * @return {string} 589 | */ 590 | proto.CustomersUpdateRequest.prototype.getId = function() { 591 | return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); 592 | }; 593 | 594 | 595 | /** 596 | * @param {string} value 597 | * @return {!proto.CustomersUpdateRequest} returns this 598 | */ 599 | proto.CustomersUpdateRequest.prototype.setId = function(value) { 600 | return jspb.Message.setProto3StringField(this, 1, value); 601 | }; 602 | 603 | 604 | /** 605 | * optional string name = 2; 606 | * @return {string} 607 | */ 608 | proto.CustomersUpdateRequest.prototype.getName = function() { 609 | return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); 610 | }; 611 | 612 | 613 | /** 614 | * @param {string} value 615 | * @return {!proto.CustomersUpdateRequest} returns this 616 | */ 617 | proto.CustomersUpdateRequest.prototype.setName = function(value) { 618 | return jspb.Message.setProto3StringField(this, 2, value); 619 | }; 620 | 621 | 622 | /** 623 | * optional int32 age = 3; 624 | * @return {number} 625 | */ 626 | proto.CustomersUpdateRequest.prototype.getAge = function() { 627 | return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); 628 | }; 629 | 630 | 631 | /** 632 | * @param {number} value 633 | * @return {!proto.CustomersUpdateRequest} returns this 634 | */ 635 | proto.CustomersUpdateRequest.prototype.setAge = function(value) { 636 | return jspb.Message.setProto3IntField(this, 3, value); 637 | }; 638 | 639 | 640 | /** 641 | * optional string address = 4; 642 | * @return {string} 643 | */ 644 | proto.CustomersUpdateRequest.prototype.getAddress = function() { 645 | return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); 646 | }; 647 | 648 | 649 | /** 650 | * @param {string} value 651 | * @return {!proto.CustomersUpdateRequest} returns this 652 | */ 653 | proto.CustomersUpdateRequest.prototype.setAddress = function(value) { 654 | return jspb.Message.setProto3StringField(this, 4, value); 655 | }; 656 | 657 | 658 | 659 | 660 | 661 | if (jspb.Message.GENERATE_TO_OBJECT) { 662 | /** 663 | * Creates an object representation of this proto. 664 | * Field names that are reserved in JavaScript and will be renamed to pb_name. 665 | * Optional fields that are not set will be set to undefined. 666 | * To access a reserved field use, foo.pb_, eg, foo.pb_default. 667 | * For the list of reserved names please see: 668 | * net/proto2/compiler/js/internal/generator.cc#kKeyword. 669 | * @param {boolean=} opt_includeInstance Deprecated. whether to include the 670 | * JSPB instance for transitional soy proto support: 671 | * http://goto/soy-param-migration 672 | * @return {!Object} 673 | */ 674 | proto.CustomersRequestId.prototype.toObject = function(opt_includeInstance) { 675 | return proto.CustomersRequestId.toObject(opt_includeInstance, this); 676 | }; 677 | 678 | 679 | /** 680 | * Static version of the {@see toObject} method. 681 | * @param {boolean|undefined} includeInstance Deprecated. Whether to include 682 | * the JSPB instance for transitional soy proto support: 683 | * http://goto/soy-param-migration 684 | * @param {!proto.CustomersRequestId} msg The msg instance to transform. 685 | * @return {!Object} 686 | * @suppress {unusedLocalVariables} f is only used for nested messages 687 | */ 688 | proto.CustomersRequestId.toObject = function(includeInstance, msg) { 689 | var f, obj = { 690 | id: jspb.Message.getFieldWithDefault(msg, 1, "") 691 | }; 692 | 693 | if (includeInstance) { 694 | obj.$jspbMessageInstance = msg; 695 | } 696 | return obj; 697 | }; 698 | } 699 | 700 | 701 | /** 702 | * Deserializes binary data (in protobuf wire format). 703 | * @param {jspb.ByteSource} bytes The bytes to deserialize. 704 | * @return {!proto.CustomersRequestId} 705 | */ 706 | proto.CustomersRequestId.deserializeBinary = function(bytes) { 707 | var reader = new jspb.BinaryReader(bytes); 708 | var msg = new proto.CustomersRequestId; 709 | return proto.CustomersRequestId.deserializeBinaryFromReader(msg, reader); 710 | }; 711 | 712 | 713 | /** 714 | * Deserializes binary data (in protobuf wire format) from the 715 | * given reader into the given message object. 716 | * @param {!proto.CustomersRequestId} msg The message object to deserialize into. 717 | * @param {!jspb.BinaryReader} reader The BinaryReader to use. 718 | * @return {!proto.CustomersRequestId} 719 | */ 720 | proto.CustomersRequestId.deserializeBinaryFromReader = function(msg, reader) { 721 | while (reader.nextField()) { 722 | if (reader.isEndGroup()) { 723 | break; 724 | } 725 | var field = reader.getFieldNumber(); 726 | switch (field) { 727 | case 1: 728 | var value = /** @type {string} */ (reader.readString()); 729 | msg.setId(value); 730 | break; 731 | default: 732 | reader.skipField(); 733 | break; 734 | } 735 | } 736 | return msg; 737 | }; 738 | 739 | 740 | /** 741 | * Serializes the message to binary data (in protobuf wire format). 742 | * @return {!Uint8Array} 743 | */ 744 | proto.CustomersRequestId.prototype.serializeBinary = function() { 745 | var writer = new jspb.BinaryWriter(); 746 | proto.CustomersRequestId.serializeBinaryToWriter(this, writer); 747 | return writer.getResultBuffer(); 748 | }; 749 | 750 | 751 | /** 752 | * Serializes the given message to binary data (in protobuf wire 753 | * format), writing to the given BinaryWriter. 754 | * @param {!proto.CustomersRequestId} message 755 | * @param {!jspb.BinaryWriter} writer 756 | * @suppress {unusedLocalVariables} f is only used for nested messages 757 | */ 758 | proto.CustomersRequestId.serializeBinaryToWriter = function(message, writer) { 759 | var f = undefined; 760 | f = message.getId(); 761 | if (f.length > 0) { 762 | writer.writeString( 763 | 1, 764 | f 765 | ); 766 | } 767 | }; 768 | 769 | 770 | /** 771 | * optional string id = 1; 772 | * @return {string} 773 | */ 774 | proto.CustomersRequestId.prototype.getId = function() { 775 | return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); 776 | }; 777 | 778 | 779 | /** 780 | * @param {string} value 781 | * @return {!proto.CustomersRequestId} returns this 782 | */ 783 | proto.CustomersRequestId.prototype.setId = function(value) { 784 | return jspb.Message.setProto3StringField(this, 1, value); 785 | }; 786 | 787 | 788 | 789 | 790 | 791 | if (jspb.Message.GENERATE_TO_OBJECT) { 792 | /** 793 | * Creates an object representation of this proto. 794 | * Field names that are reserved in JavaScript and will be renamed to pb_name. 795 | * Optional fields that are not set will be set to undefined. 796 | * To access a reserved field use, foo.pb_, eg, foo.pb_default. 797 | * For the list of reserved names please see: 798 | * net/proto2/compiler/js/internal/generator.cc#kKeyword. 799 | * @param {boolean=} opt_includeInstance Deprecated. whether to include the 800 | * JSPB instance for transitional soy proto support: 801 | * http://goto/soy-param-migration 802 | * @return {!Object} 803 | */ 804 | proto.CustomersResponse.prototype.toObject = function(opt_includeInstance) { 805 | return proto.CustomersResponse.toObject(opt_includeInstance, this); 806 | }; 807 | 808 | 809 | /** 810 | * Static version of the {@see toObject} method. 811 | * @param {boolean|undefined} includeInstance Deprecated. Whether to include 812 | * the JSPB instance for transitional soy proto support: 813 | * http://goto/soy-param-migration 814 | * @param {!proto.CustomersResponse} msg The msg instance to transform. 815 | * @return {!Object} 816 | * @suppress {unusedLocalVariables} f is only used for nested messages 817 | */ 818 | proto.CustomersResponse.toObject = function(includeInstance, msg) { 819 | var f, obj = { 820 | id: jspb.Message.getFieldWithDefault(msg, 1, ""), 821 | name: jspb.Message.getFieldWithDefault(msg, 2, ""), 822 | age: jspb.Message.getFieldWithDefault(msg, 3, 0), 823 | address: jspb.Message.getFieldWithDefault(msg, 4, "") 824 | }; 825 | 826 | if (includeInstance) { 827 | obj.$jspbMessageInstance = msg; 828 | } 829 | return obj; 830 | }; 831 | } 832 | 833 | 834 | /** 835 | * Deserializes binary data (in protobuf wire format). 836 | * @param {jspb.ByteSource} bytes The bytes to deserialize. 837 | * @return {!proto.CustomersResponse} 838 | */ 839 | proto.CustomersResponse.deserializeBinary = function(bytes) { 840 | var reader = new jspb.BinaryReader(bytes); 841 | var msg = new proto.CustomersResponse; 842 | return proto.CustomersResponse.deserializeBinaryFromReader(msg, reader); 843 | }; 844 | 845 | 846 | /** 847 | * Deserializes binary data (in protobuf wire format) from the 848 | * given reader into the given message object. 849 | * @param {!proto.CustomersResponse} msg The message object to deserialize into. 850 | * @param {!jspb.BinaryReader} reader The BinaryReader to use. 851 | * @return {!proto.CustomersResponse} 852 | */ 853 | proto.CustomersResponse.deserializeBinaryFromReader = function(msg, reader) { 854 | while (reader.nextField()) { 855 | if (reader.isEndGroup()) { 856 | break; 857 | } 858 | var field = reader.getFieldNumber(); 859 | switch (field) { 860 | case 1: 861 | var value = /** @type {string} */ (reader.readString()); 862 | msg.setId(value); 863 | break; 864 | case 2: 865 | var value = /** @type {string} */ (reader.readString()); 866 | msg.setName(value); 867 | break; 868 | case 3: 869 | var value = /** @type {number} */ (reader.readInt32()); 870 | msg.setAge(value); 871 | break; 872 | case 4: 873 | var value = /** @type {string} */ (reader.readString()); 874 | msg.setAddress(value); 875 | break; 876 | default: 877 | reader.skipField(); 878 | break; 879 | } 880 | } 881 | return msg; 882 | }; 883 | 884 | 885 | /** 886 | * Serializes the message to binary data (in protobuf wire format). 887 | * @return {!Uint8Array} 888 | */ 889 | proto.CustomersResponse.prototype.serializeBinary = function() { 890 | var writer = new jspb.BinaryWriter(); 891 | proto.CustomersResponse.serializeBinaryToWriter(this, writer); 892 | return writer.getResultBuffer(); 893 | }; 894 | 895 | 896 | /** 897 | * Serializes the given message to binary data (in protobuf wire 898 | * format), writing to the given BinaryWriter. 899 | * @param {!proto.CustomersResponse} message 900 | * @param {!jspb.BinaryWriter} writer 901 | * @suppress {unusedLocalVariables} f is only used for nested messages 902 | */ 903 | proto.CustomersResponse.serializeBinaryToWriter = function(message, writer) { 904 | var f = undefined; 905 | f = message.getId(); 906 | if (f.length > 0) { 907 | writer.writeString( 908 | 1, 909 | f 910 | ); 911 | } 912 | f = message.getName(); 913 | if (f.length > 0) { 914 | writer.writeString( 915 | 2, 916 | f 917 | ); 918 | } 919 | f = message.getAge(); 920 | if (f !== 0) { 921 | writer.writeInt32( 922 | 3, 923 | f 924 | ); 925 | } 926 | f = message.getAddress(); 927 | if (f.length > 0) { 928 | writer.writeString( 929 | 4, 930 | f 931 | ); 932 | } 933 | }; 934 | 935 | 936 | /** 937 | * optional string id = 1; 938 | * @return {string} 939 | */ 940 | proto.CustomersResponse.prototype.getId = function() { 941 | return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); 942 | }; 943 | 944 | 945 | /** 946 | * @param {string} value 947 | * @return {!proto.CustomersResponse} returns this 948 | */ 949 | proto.CustomersResponse.prototype.setId = function(value) { 950 | return jspb.Message.setProto3StringField(this, 1, value); 951 | }; 952 | 953 | 954 | /** 955 | * optional string name = 2; 956 | * @return {string} 957 | */ 958 | proto.CustomersResponse.prototype.getName = function() { 959 | return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); 960 | }; 961 | 962 | 963 | /** 964 | * @param {string} value 965 | * @return {!proto.CustomersResponse} returns this 966 | */ 967 | proto.CustomersResponse.prototype.setName = function(value) { 968 | return jspb.Message.setProto3StringField(this, 2, value); 969 | }; 970 | 971 | 972 | /** 973 | * optional int32 age = 3; 974 | * @return {number} 975 | */ 976 | proto.CustomersResponse.prototype.getAge = function() { 977 | return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); 978 | }; 979 | 980 | 981 | /** 982 | * @param {number} value 983 | * @return {!proto.CustomersResponse} returns this 984 | */ 985 | proto.CustomersResponse.prototype.setAge = function(value) { 986 | return jspb.Message.setProto3IntField(this, 3, value); 987 | }; 988 | 989 | 990 | /** 991 | * optional string address = 4; 992 | * @return {string} 993 | */ 994 | proto.CustomersResponse.prototype.getAddress = function() { 995 | return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); 996 | }; 997 | 998 | 999 | /** 1000 | * @param {string} value 1001 | * @return {!proto.CustomersResponse} returns this 1002 | */ 1003 | proto.CustomersResponse.prototype.setAddress = function(value) { 1004 | return jspb.Message.setProto3StringField(this, 4, value); 1005 | }; 1006 | 1007 | 1008 | 1009 | /** 1010 | * List of repeated fields within this message type. 1011 | * @private {!Array} 1012 | * @const 1013 | */ 1014 | proto.CustomersResponseList.repeatedFields_ = [1]; 1015 | 1016 | 1017 | 1018 | if (jspb.Message.GENERATE_TO_OBJECT) { 1019 | /** 1020 | * Creates an object representation of this proto. 1021 | * Field names that are reserved in JavaScript and will be renamed to pb_name. 1022 | * Optional fields that are not set will be set to undefined. 1023 | * To access a reserved field use, foo.pb_, eg, foo.pb_default. 1024 | * For the list of reserved names please see: 1025 | * net/proto2/compiler/js/internal/generator.cc#kKeyword. 1026 | * @param {boolean=} opt_includeInstance Deprecated. whether to include the 1027 | * JSPB instance for transitional soy proto support: 1028 | * http://goto/soy-param-migration 1029 | * @return {!Object} 1030 | */ 1031 | proto.CustomersResponseList.prototype.toObject = function(opt_includeInstance) { 1032 | return proto.CustomersResponseList.toObject(opt_includeInstance, this); 1033 | }; 1034 | 1035 | 1036 | /** 1037 | * Static version of the {@see toObject} method. 1038 | * @param {boolean|undefined} includeInstance Deprecated. Whether to include 1039 | * the JSPB instance for transitional soy proto support: 1040 | * http://goto/soy-param-migration 1041 | * @param {!proto.CustomersResponseList} msg The msg instance to transform. 1042 | * @return {!Object} 1043 | * @suppress {unusedLocalVariables} f is only used for nested messages 1044 | */ 1045 | proto.CustomersResponseList.toObject = function(includeInstance, msg) { 1046 | var f, obj = { 1047 | customersresponselistList: jspb.Message.toObjectList(msg.getCustomersresponselistList(), 1048 | proto.CustomersResponse.toObject, includeInstance) 1049 | }; 1050 | 1051 | if (includeInstance) { 1052 | obj.$jspbMessageInstance = msg; 1053 | } 1054 | return obj; 1055 | }; 1056 | } 1057 | 1058 | 1059 | /** 1060 | * Deserializes binary data (in protobuf wire format). 1061 | * @param {jspb.ByteSource} bytes The bytes to deserialize. 1062 | * @return {!proto.CustomersResponseList} 1063 | */ 1064 | proto.CustomersResponseList.deserializeBinary = function(bytes) { 1065 | var reader = new jspb.BinaryReader(bytes); 1066 | var msg = new proto.CustomersResponseList; 1067 | return proto.CustomersResponseList.deserializeBinaryFromReader(msg, reader); 1068 | }; 1069 | 1070 | 1071 | /** 1072 | * Deserializes binary data (in protobuf wire format) from the 1073 | * given reader into the given message object. 1074 | * @param {!proto.CustomersResponseList} msg The message object to deserialize into. 1075 | * @param {!jspb.BinaryReader} reader The BinaryReader to use. 1076 | * @return {!proto.CustomersResponseList} 1077 | */ 1078 | proto.CustomersResponseList.deserializeBinaryFromReader = function(msg, reader) { 1079 | while (reader.nextField()) { 1080 | if (reader.isEndGroup()) { 1081 | break; 1082 | } 1083 | var field = reader.getFieldNumber(); 1084 | switch (field) { 1085 | case 1: 1086 | var value = new proto.CustomersResponse; 1087 | reader.readMessage(value,proto.CustomersResponse.deserializeBinaryFromReader); 1088 | msg.addCustomersresponselist(value); 1089 | break; 1090 | default: 1091 | reader.skipField(); 1092 | break; 1093 | } 1094 | } 1095 | return msg; 1096 | }; 1097 | 1098 | 1099 | /** 1100 | * Serializes the message to binary data (in protobuf wire format). 1101 | * @return {!Uint8Array} 1102 | */ 1103 | proto.CustomersResponseList.prototype.serializeBinary = function() { 1104 | var writer = new jspb.BinaryWriter(); 1105 | proto.CustomersResponseList.serializeBinaryToWriter(this, writer); 1106 | return writer.getResultBuffer(); 1107 | }; 1108 | 1109 | 1110 | /** 1111 | * Serializes the given message to binary data (in protobuf wire 1112 | * format), writing to the given BinaryWriter. 1113 | * @param {!proto.CustomersResponseList} message 1114 | * @param {!jspb.BinaryWriter} writer 1115 | * @suppress {unusedLocalVariables} f is only used for nested messages 1116 | */ 1117 | proto.CustomersResponseList.serializeBinaryToWriter = function(message, writer) { 1118 | var f = undefined; 1119 | f = message.getCustomersresponselistList(); 1120 | if (f.length > 0) { 1121 | writer.writeRepeatedMessage( 1122 | 1, 1123 | f, 1124 | proto.CustomersResponse.serializeBinaryToWriter 1125 | ); 1126 | } 1127 | }; 1128 | 1129 | 1130 | /** 1131 | * repeated CustomersResponse customersResponseList = 1; 1132 | * @return {!Array} 1133 | */ 1134 | proto.CustomersResponseList.prototype.getCustomersresponselistList = function() { 1135 | return /** @type{!Array} */ ( 1136 | jspb.Message.getRepeatedWrapperField(this, proto.CustomersResponse, 1)); 1137 | }; 1138 | 1139 | 1140 | /** 1141 | * @param {!Array} value 1142 | * @return {!proto.CustomersResponseList} returns this 1143 | */ 1144 | proto.CustomersResponseList.prototype.setCustomersresponselistList = function(value) { 1145 | return jspb.Message.setRepeatedWrapperField(this, 1, value); 1146 | }; 1147 | 1148 | 1149 | /** 1150 | * @param {!proto.CustomersResponse=} opt_value 1151 | * @param {number=} opt_index 1152 | * @return {!proto.CustomersResponse} 1153 | */ 1154 | proto.CustomersResponseList.prototype.addCustomersresponselist = function(opt_value, opt_index) { 1155 | return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.CustomersResponse, opt_index); 1156 | }; 1157 | 1158 | 1159 | /** 1160 | * Clears the list making it empty but non-null. 1161 | * @return {!proto.CustomersResponseList} returns this 1162 | */ 1163 | proto.CustomersResponseList.prototype.clearCustomersresponselistList = function() { 1164 | return this.setCustomersresponselistList([]); 1165 | }; 1166 | 1167 | 1168 | goog.object.extend(exports, proto); 1169 | --------------------------------------------------------------------------------