gomtm 0.0.227 → 0.0.229

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import { ServiceType } from "@bufbuild/protobuf";
2
2
  export declare const ssrGetBackendUrl: () => string;
3
+ export declare const gomtmApiUrl: () => string;
3
4
  export declare function createMtmServiceClient<T extends ServiceType>(service: T, url?: string): import("@connectrpc/connect").PromiseClient<T>;
4
5
  export declare function createMtmServiceClientByName<T extends ServiceType>(svcName: string, url?: string): import("@connectrpc/connect").PromiseClient<ServiceType>;
5
6
  type CustomRequestInit = RequestInit & {
@@ -51,24 +51,22 @@ const ssrGetBackendUrl = () => {
51
51
  }
52
52
  return "";
53
53
  };
54
- function createMtmServiceClient(service, url) {
54
+ const gomtmApiUrl = () => {
55
55
  const baseUrl = ssrGetBackendUrl();
56
56
  const apiUrl = new URL(MTM_API_PREFIX, baseUrl).toString();
57
57
  console.info("gomtm apiUrl:", baseUrl);
58
+ return apiUrl;
59
+ };
60
+ function createMtmServiceClient(service, url) {
58
61
  return createPromiseClient(
59
62
  service,
60
63
  createConnectTransport({
61
- baseUrl: apiUrl,
64
+ baseUrl: gomtmApiUrl(),
62
65
  fetch: gomtmFetcher()
63
66
  })
64
67
  );
65
68
  }
66
69
  function createMtmServiceClientByName(svcName, url) {
67
- const baseUrl = url || process.env.MTM_BACKEND;
68
- if (!baseUrl) {
69
- throw new Error("missing mtm api url,\xB7MTM_BACKEND\xB7");
70
- }
71
- console.info("gomtm baseUrl:", baseUrl);
72
70
  let svcType = void 0;
73
71
  for (const a of allServices) {
74
72
  if (a.typeName == svcName) {
@@ -81,7 +79,7 @@ function createMtmServiceClientByName(svcName, url) {
81
79
  return createPromiseClient(
82
80
  svcType,
83
81
  createConnectTransport({
84
- baseUrl,
82
+ baseUrl: gomtmApiUrl(),
85
83
  fetch: gomtmFetcher()
86
84
  })
87
85
  );
@@ -136,6 +134,7 @@ const gomtmFetcher = (initGlobal) => {
136
134
  export {
137
135
  createMtmServiceClient,
138
136
  createMtmServiceClientByName,
137
+ gomtmApiUrl,
139
138
  gomtmFetcher,
140
139
  ssrGetBackendUrl
141
140
  };