mirror of
https://github.com/geoffsee/open-gsio.git
synced 2025-09-08 22:56:46 +00:00
change semantics
Update README deployment steps and add deploy:secrets script to package.json update local inference script and README update lockfile reconfigure package scripts for development update test execution pass server tests Update README with revised Bun commands and workspace details remove pnpm package manager designator create bun server
This commit is contained in:

committed by
Geoff Seemueller

parent
1055cda2f1
commit
497eb22ad8
38
packages/server/services/MetricsService.ts
Normal file
38
packages/server/services/MetricsService.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { types, flow } from "mobx-state-tree";
|
||||
|
||||
const MetricsService = types
|
||||
.model("MetricsService", {
|
||||
isCollectingMetrics: types.optional(types.boolean, true),
|
||||
})
|
||||
.volatile((self) => ({
|
||||
env: {} as Env,
|
||||
ctx: {} as ExecutionContext,
|
||||
}))
|
||||
.actions((self) => ({
|
||||
setEnv(env: Env) {
|
||||
self.env = env;
|
||||
},
|
||||
setCtx(ctx: ExecutionContext) {
|
||||
self.ctx = ctx;
|
||||
},
|
||||
handleMetricsRequest: flow(function* (request: Request) {
|
||||
const url = new URL(request.url);
|
||||
const proxyUrl = `https://metrics.seemueller.io${url.pathname}${url.search}`;
|
||||
|
||||
try {
|
||||
const response = yield fetch(proxyUrl, {
|
||||
method: request.method,
|
||||
headers: request.headers,
|
||||
body: ["GET", "HEAD"].includes(request.method) ? null : request.body,
|
||||
redirect: "follow",
|
||||
});
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error("Failed to proxy metrics request:", error);
|
||||
return new Response("Failed to fetch metrics", { status: 500 });
|
||||
}
|
||||
}),
|
||||
}));
|
||||
|
||||
export default MetricsService;
|
Reference in New Issue
Block a user