@checkmate-monitor/frontend 0.1.0 → 0.1.1
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.
- package/CHANGELOG.md +20 -0
- package/package.json +1 -1
- package/src/App.tsx +31 -5
- package/src/apis/fetch-api.ts +6 -4
- package/src/apis/rpc-api.ts +1 -4
- package/vite.config.ts +6 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @checkmate-monitor/frontend
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0f8cc7d: Add runtime configuration API for Docker deployments
|
|
8
|
+
|
|
9
|
+
- Backend: Add `/api/config` endpoint serving `BASE_URL` at runtime
|
|
10
|
+
- Backend: Update CORS to use `BASE_URL` and auto-allow Vite dev server
|
|
11
|
+
- Backend: `INTERNAL_URL` now defaults to `localhost:3000` (no BASE_URL fallback)
|
|
12
|
+
- Frontend API: Add `RuntimeConfigProvider` context for runtime config
|
|
13
|
+
- Frontend: Use `RuntimeConfigProvider` from `frontend-api`
|
|
14
|
+
- Auth Frontend: Add `useAuthClient()` hook using runtime config
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [0f8cc7d]
|
|
17
|
+
- @checkmate-monitor/frontend-api@0.0.3
|
|
18
|
+
- @checkmate-monitor/auth-frontend@0.1.1
|
|
19
|
+
- @checkmate-monitor/catalog-frontend@0.0.3
|
|
20
|
+
- @checkmate-monitor/command-frontend@0.0.3
|
|
21
|
+
- @checkmate-monitor/ui@0.1.1
|
|
22
|
+
|
|
3
23
|
## 0.1.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -19,6 +19,9 @@ import {
|
|
|
19
19
|
DashboardSlot,
|
|
20
20
|
NavbarSlot,
|
|
21
21
|
NavbarMainSlot,
|
|
22
|
+
RuntimeConfigProvider,
|
|
23
|
+
useRuntimeConfigLoading,
|
|
24
|
+
useRuntimeConfig,
|
|
22
25
|
} from "@checkmate-monitor/frontend-api";
|
|
23
26
|
import { ConsoleLoggerApi } from "./apis/logger-api";
|
|
24
27
|
import { CoreFetchApi } from "./apis/fetch-api";
|
|
@@ -131,7 +134,13 @@ function AppContent() {
|
|
|
131
134
|
);
|
|
132
135
|
}
|
|
133
136
|
|
|
134
|
-
|
|
137
|
+
/**
|
|
138
|
+
* App wrapper that provides APIs and waits for runtime config to load.
|
|
139
|
+
*/
|
|
140
|
+
function AppWithApis() {
|
|
141
|
+
const isConfigLoading = useRuntimeConfigLoading();
|
|
142
|
+
const { baseUrl } = useRuntimeConfig();
|
|
143
|
+
|
|
135
144
|
const apiRegistry = useMemo(() => {
|
|
136
145
|
// Initialize API Registry with core apiRefs
|
|
137
146
|
const registryBuilder = new ApiRegistryBuilder()
|
|
@@ -142,10 +151,10 @@ function App() {
|
|
|
142
151
|
useManagePermission: () => ({ loading: false, allowed: true }),
|
|
143
152
|
})
|
|
144
153
|
.registerFactory(fetchApiRef, (_registry) => {
|
|
145
|
-
return new CoreFetchApi();
|
|
154
|
+
return new CoreFetchApi(baseUrl);
|
|
146
155
|
})
|
|
147
156
|
.registerFactory(rpcApiRef, (_registry) => {
|
|
148
|
-
return new CoreRpcApi();
|
|
157
|
+
return new CoreRpcApi(baseUrl);
|
|
149
158
|
});
|
|
150
159
|
|
|
151
160
|
// Register API factories from plugins
|
|
@@ -165,11 +174,20 @@ function App() {
|
|
|
165
174
|
}
|
|
166
175
|
|
|
167
176
|
return registryBuilder.build();
|
|
168
|
-
}, []);
|
|
177
|
+
}, [baseUrl]);
|
|
178
|
+
|
|
179
|
+
// Show loading while fetching runtime config
|
|
180
|
+
if (isConfigLoading) {
|
|
181
|
+
return (
|
|
182
|
+
<div className="h-screen flex items-center justify-center bg-background">
|
|
183
|
+
<LoadingSpinner />
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
169
187
|
|
|
170
188
|
return (
|
|
171
189
|
<ApiProvider registry={apiRegistry}>
|
|
172
|
-
<SignalProvider>
|
|
190
|
+
<SignalProvider backendUrl={baseUrl}>
|
|
173
191
|
<ToastProvider>
|
|
174
192
|
<AppContent />
|
|
175
193
|
</ToastProvider>
|
|
@@ -178,4 +196,12 @@ function App() {
|
|
|
178
196
|
);
|
|
179
197
|
}
|
|
180
198
|
|
|
199
|
+
function App() {
|
|
200
|
+
return (
|
|
201
|
+
<RuntimeConfigProvider>
|
|
202
|
+
<AppWithApis />
|
|
203
|
+
</RuntimeConfigProvider>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
181
207
|
export default App;
|
package/src/apis/fetch-api.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { FetchApi } from "@checkmate-monitor/frontend-api";
|
|
2
2
|
|
|
3
3
|
export class CoreFetchApi implements FetchApi {
|
|
4
|
-
|
|
4
|
+
private baseUrl: string;
|
|
5
|
+
|
|
6
|
+
constructor(baseUrl: string = "http://localhost:3000") {
|
|
7
|
+
this.baseUrl = baseUrl;
|
|
8
|
+
}
|
|
5
9
|
|
|
6
10
|
async fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
|
|
7
11
|
const headers = new Headers(init?.headers);
|
|
@@ -18,9 +22,7 @@ export class CoreFetchApi implements FetchApi {
|
|
|
18
22
|
} {
|
|
19
23
|
return {
|
|
20
24
|
fetch: (path: string, init?: RequestInit) => {
|
|
21
|
-
|
|
22
|
-
import.meta.env.VITE_API_BASE_URL || "http://localhost:3000";
|
|
23
|
-
return this.fetch(`${baseUrl}/api/${pluginId}${path}`, init);
|
|
25
|
+
return this.fetch(`${this.baseUrl}/api/${pluginId}${path}`, init);
|
|
24
26
|
},
|
|
25
27
|
};
|
|
26
28
|
}
|
package/src/apis/rpc-api.ts
CHANGED
|
@@ -7,10 +7,7 @@ export class CoreRpcApi implements RpcApi {
|
|
|
7
7
|
public client: unknown;
|
|
8
8
|
private pluginClientCache: Map<string, unknown> = new Map();
|
|
9
9
|
|
|
10
|
-
constructor() {
|
|
11
|
-
const baseUrl =
|
|
12
|
-
import.meta.env.VITE_API_BASE_URL || "http://localhost:3000";
|
|
13
|
-
|
|
10
|
+
constructor(baseUrl: string = "http://localhost:3000") {
|
|
14
11
|
const link = new RPCLink({
|
|
15
12
|
url: `${baseUrl}/api`,
|
|
16
13
|
fetch: (input: RequestInfo | URL, init?: RequestInit) =>
|
package/vite.config.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineConfig
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
2
|
import react from "@vitejs/plugin-react";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
@@ -6,10 +6,9 @@ import path from "node:path";
|
|
|
6
6
|
const monorepoRoot = path.resolve(__dirname, "../..");
|
|
7
7
|
|
|
8
8
|
// https://vitejs.dev/config/
|
|
9
|
-
export default defineConfig((
|
|
10
|
-
//
|
|
11
|
-
const
|
|
12
|
-
const target = env.VITE_API_BASE_URL || "http://localhost:3000";
|
|
9
|
+
export default defineConfig(() => {
|
|
10
|
+
// Backend URL for proxy - always targets local backend in dev
|
|
11
|
+
const backendUrl = "http://localhost:3000";
|
|
13
12
|
return {
|
|
14
13
|
// Tell Vite to look for .env files in monorepo root
|
|
15
14
|
envDir: monorepoRoot,
|
|
@@ -19,10 +18,10 @@ export default defineConfig(({ mode }) => {
|
|
|
19
18
|
// Proxy API requests and WebSocket connections to backend
|
|
20
19
|
// Use regex to ensure /api-docs doesn't match (it starts with /api but isn't an API call)
|
|
21
20
|
"^/api/": {
|
|
22
|
-
target,
|
|
21
|
+
target: backendUrl,
|
|
23
22
|
ws: true, // Enable WebSocket proxy
|
|
24
23
|
},
|
|
25
|
-
"/assets":
|
|
24
|
+
"/assets": backendUrl,
|
|
26
25
|
},
|
|
27
26
|
},
|
|
28
27
|
// ============================================================
|