api/

directory
v0.0.0-...-ae3587a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2020 License: LGPL-3.0

README

SMAG gRPC Web API

About

In our project we are using a gRPC Web API. For that we are using an envoy proxy to be able to connect to the gRPC Server. As our system is not publicly accessible an AWS Account in our Organisation with the appropriate access is required.

Requirements

In order to successfully use our api make sure to have:

  • a running kubernetes setup (permssion required)
  • optional for local testing: protoc to generate the protofiles for the frontend

Usage

To use the production enviroment do the following steps:

  1. Get name of envoy proxy kubectl get pods | grep envoy
  2. Forward the envoy-pod port with kubectl port-forward envoy-proxy-deployment-6b89675d5b-d86c4 4000:8080
  3. To make use of the API in the React Frontend import and run the following:
    import {
      User,
      UserNameRequest,
      UserIdRequest,
      InstaPostsResponse,
      UserSearchResponse
    } from "./protofiles/client/usersearch_pb.js";
    import { UserSearchServiceClient } from "./protofiles/client/usersearch_grpc_web_pb.js";
    var userSearch = new UserSearchServiceClient("http://localhost:4000");
    var request = new UserName();
    request.setUserName("codeuniversity");
    userSearch.getUserWithUsername(request, {}, function(err, response) {
      //example function call...
    });
    

Functions

To check the attributes of the proto messages take a look at the protofile userserach.proto

Method Function Name Input Message Return Message
GET getUserWithUsername UserNameRequest User
GET getAllUsersLikeUsername UserNameRequest UserSearchResponse
GET getTaggedPostsWithUserId UserIdRequest InstaPostsResponse
GET getInstaPostssWithUserid UserIdRequest UserSearchResponse

Directories

Path Synopsis
main command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL