feat: impl grpcweb in frontend

This commit is contained in:
Steven
2023-09-20 21:49:13 +08:00
parent 9e8de4644a
commit ebe54d1131
11 changed files with 469 additions and 26 deletions

View File

@ -0,0 +1,18 @@
import { createChannel, createClientFactory, FetchTransport } from "nice-grpc-web";
import { UserServiceDefinition } from "./types/proto/api/v2/user_service";
import { WorkspaceSettingServiceDefinition } from "./types/proto/api/v2/workspace_setting_service";
const address = import.meta.env.MODE === "development" ? "http://localhost:8082" : window.location.origin;
const channel = createChannel(
address,
FetchTransport({
credentials: "include",
})
);
const clientFactory = createClientFactory();
export const userServiceClient = clientFactory.create(UserServiceDefinition, channel);
export const workspaceSettingServiceClient = clientFactory.create(WorkspaceSettingServiceDefinition, channel);