refactor: impl part of grpcweb

This commit is contained in:
Steven
2023-09-17 19:20:03 +08:00
parent d5c1706e9c
commit 72ca4e74ee
20 changed files with 3325 additions and 26 deletions

15
web/src/grpcweb.ts Normal file
View File

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