grpcweb.ts 1.1 KB

12345678910111213141516171819202122232425
  1. import { createChannel, createClientFactory, FetchTransport } from "nice-grpc-web";
  2. import { MemoServiceDefinition } from "./types/proto/api/v2/memo_service";
  3. import { ResourceServiceDefinition } from "./types/proto/api/v2/resource_service";
  4. import { SystemServiceDefinition } from "./types/proto/api/v2/system_service";
  5. import { TagServiceDefinition } from "./types/proto/api/v2/tag_service";
  6. import { UserServiceDefinition } from "./types/proto/api/v2/user_service";
  7. const channel = createChannel(
  8. window.location.origin,
  9. FetchTransport({
  10. credentials: "include",
  11. })
  12. );
  13. const clientFactory = createClientFactory();
  14. export const userServiceClient = clientFactory.create(UserServiceDefinition, channel);
  15. export const memoServiceClient = clientFactory.create(MemoServiceDefinition, channel);
  16. export const resourceServiceClient = clientFactory.create(ResourceServiceDefinition, channel);
  17. export const systemServiceClient = clientFactory.create(SystemServiceDefinition, channel);
  18. export const tagServiceClient = clientFactory.create(TagServiceDefinition, channel);