@checkmate-monitor/backend 0.1.1 → 0.1.2
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 +13 -0
- package/package.json +1 -1
- package/src/index.ts +19 -2
- package/src/plugin-manager/core-services.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @checkmate-monitor/backend
|
|
2
2
|
|
|
3
|
+
## 0.1.2
|
|
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
|
+
|
|
3
16
|
## 0.1.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -37,10 +37,21 @@ const pluginManager = new PluginManager();
|
|
|
37
37
|
// WebSocket handler instance (initialized during init)
|
|
38
38
|
let wsHandler: ReturnType<typeof createWebSocketHandler> | undefined;
|
|
39
39
|
|
|
40
|
+
// CORS configuration
|
|
41
|
+
// - In production: uses BASE_URL
|
|
42
|
+
// - In development: allows both backend origin and Vite dev server
|
|
43
|
+
const corsOrigin = process.env.BASE_URL || "http://localhost:3000";
|
|
44
|
+
const corsOrigins = [corsOrigin];
|
|
45
|
+
|
|
46
|
+
// Allow Vite dev server in development
|
|
47
|
+
if (!process.env.BASE_URL || corsOrigin.includes("localhost")) {
|
|
48
|
+
corsOrigins.push("http://localhost:5173");
|
|
49
|
+
}
|
|
50
|
+
|
|
40
51
|
app.use(
|
|
41
52
|
"*",
|
|
42
53
|
cors({
|
|
43
|
-
origin:
|
|
54
|
+
origin: corsOrigins,
|
|
44
55
|
allowHeaders: ["Content-Type", "Authorization"],
|
|
45
56
|
allowMethods: ["POST", "GET", "PUT", "PATCH", "DELETE", "OPTIONS"],
|
|
46
57
|
exposeHeaders: ["Content-Length"],
|
|
@@ -50,6 +61,12 @@ app.use(
|
|
|
50
61
|
);
|
|
51
62
|
app.use("*", logger());
|
|
52
63
|
|
|
64
|
+
// Runtime config endpoint - returns BASE_URL for frontend
|
|
65
|
+
app.get("/api/config", (c) => {
|
|
66
|
+
const baseUrl = process.env.BASE_URL || "http://localhost:3000";
|
|
67
|
+
return c.json({ baseUrl });
|
|
68
|
+
});
|
|
69
|
+
|
|
53
70
|
app.get("/api/plugins", async (c) => {
|
|
54
71
|
// Only return remote plugins that need to be loaded via HTTP
|
|
55
72
|
// Local plugins are bundled and loaded via Vite's glob import
|
|
@@ -219,7 +236,7 @@ const init = async () => {
|
|
|
219
236
|
const authService = await pluginManager.getService(coreServices.auth);
|
|
220
237
|
if (authService) {
|
|
221
238
|
const { createOpenApiHandler } = await import("./openapi-router");
|
|
222
|
-
const baseUrl = process.env.
|
|
239
|
+
const baseUrl = process.env.BASE_URL || "http://localhost:3000";
|
|
223
240
|
const openApiHandler = createOpenApiHandler({
|
|
224
241
|
pluginManager,
|
|
225
242
|
authService,
|
|
@@ -176,7 +176,7 @@ export function registerCoreServices({
|
|
|
176
176
|
// 4. Fetch Factory (Scoped)
|
|
177
177
|
registry.registerFactory(coreServices.fetch, async (metadata) => {
|
|
178
178
|
const auth = await registry.get(coreServices.auth, metadata);
|
|
179
|
-
const apiBaseUrl = process.env.
|
|
179
|
+
const apiBaseUrl = process.env.INTERNAL_URL || "http://localhost:3000";
|
|
180
180
|
|
|
181
181
|
const fetchWithAuth = async (
|
|
182
182
|
input: RequestInfo | URL,
|
|
@@ -237,7 +237,7 @@ export function registerCoreServices({
|
|
|
237
237
|
// 5. RPC Client Factory (Scoped, Typed)
|
|
238
238
|
registry.registerFactory(coreServices.rpcClient, async (metadata) => {
|
|
239
239
|
const fetchService = await registry.get(coreServices.fetch, metadata);
|
|
240
|
-
const apiBaseUrl = process.env.
|
|
240
|
+
const apiBaseUrl = process.env.INTERNAL_URL || "http://localhost:3000";
|
|
241
241
|
|
|
242
242
|
// Create RPC Link using the fetch service (already has auth)
|
|
243
243
|
const link = new RPCLink({
|