feat(opsserver): add health, audit, cluster health, and durable credential management hardening
This commit is contained in:
@@ -16,6 +16,7 @@ export class OpsServer {
|
||||
public configHandler!: handlers.ConfigHandler;
|
||||
public credentialsHandler!: handlers.CredentialsHandler;
|
||||
public policiesHandler!: handlers.PoliciesHandler;
|
||||
public auditHandler!: handlers.AuditHandler;
|
||||
|
||||
constructor(objectStorageRef: ObjectStorageContainer) {
|
||||
this.objectStorageRef = objectStorageRef;
|
||||
@@ -26,6 +27,27 @@ export class OpsServer {
|
||||
domain: 'localhost',
|
||||
feedMetadata: undefined,
|
||||
bundledContent: bundledFiles,
|
||||
addCustomRoutes: async (typedserver) => {
|
||||
typedserver.addRoute('/livez', 'GET', async () => {
|
||||
return this.jsonResponse({ ok: true, status: 'alive' });
|
||||
});
|
||||
typedserver.addRoute('/readyz', 'GET', async () => {
|
||||
const ready = await this.objectStorageRef.isReady();
|
||||
return this.jsonResponse(
|
||||
{ ok: ready, status: ready ? 'ready' : 'starting' },
|
||||
ready ? 200 : 503,
|
||||
);
|
||||
});
|
||||
typedserver.addRoute('/healthz', 'GET', async () => {
|
||||
return this.jsonResponse(await this.objectStorageRef.getOperationalHealth());
|
||||
});
|
||||
typedserver.addRoute('/metrics', 'GET', async () => {
|
||||
const metrics = await this.objectStorageRef.getOperationalMetrics();
|
||||
return new Response(metrics, {
|
||||
headers: { 'content-type': 'text/plain; version=0.0.4' },
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
// Chain typedrouters: server -> opsServer -> individual handlers
|
||||
@@ -50,6 +72,7 @@ export class OpsServer {
|
||||
this.configHandler = new handlers.ConfigHandler(this);
|
||||
this.credentialsHandler = new handlers.CredentialsHandler(this);
|
||||
this.policiesHandler = new handlers.PoliciesHandler(this);
|
||||
this.auditHandler = new handlers.AuditHandler(this);
|
||||
|
||||
console.log('OpsServer TypedRequest handlers initialized');
|
||||
}
|
||||
@@ -60,4 +83,11 @@ export class OpsServer {
|
||||
console.log('OpsServer stopped');
|
||||
}
|
||||
}
|
||||
|
||||
private jsonResponse(data: unknown, status = 200): Response {
|
||||
return new Response(JSON.stringify(data), {
|
||||
status,
|
||||
headers: { 'content-type': 'application/json' },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user