How to use the grpc-web.StatusCode.NOT_FOUND function in grpc-web

To help you get started, weโ€™ve selected a few grpc-web examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pipe-cd / pipe / pkg / app / web / src / modules / application-counts.ts View on Github external
const res = await getApplicationCount().catch((e: { code: number }) => {
      // NOT_FOUND is the initial normal state, so it is excluded from error handling.
      if (e.code !== StatusCode.NOT_FOUND) {
        throw e;
      }
    });
github pipe-cd / pipe / pkg / app / web / src / mocks / services / insight.ts View on Github external
import { createHandler, createHandlerWithError } from "../create-handler";

export const getInsightApplicationCountHandler = createHandler<
  GetInsightApplicationCountResponse
>("/GetInsightApplicationCount", () => {
  const response = new GetInsightApplicationCountResponse();
  response.setUpdatedAt(createRandTime().unix());
  response.setCountsList(
    dummyApplicationCounts.map(createInsightApplicationCountFromObject)
  );
  return response;
});

export const getInsightApplicationCountNotFound = createHandlerWithError(
  "/GetInsightApplicationCount",
  StatusCode.NOT_FOUND
);

export const insightHandlers = [
  getInsightApplicationCountHandler,
  createHandler("/GetInsightData", () => {
    const response = new GetInsightDataResponse();
    response.setUpdatedAt(1);
    response.setMatrixList([]);
    const dataPointsList = createDataPointsListFromObject(dummyDataPointsList);
    const insightSampleStream = new InsightSampleStream();
    insightSampleStream.setDataPointsList(dataPointsList);
    response.setVectorList([]);
    response.setDataPointsList(dataPointsList);
    response.setType(InsightResultType.MATRIX);
    return response;
  }),