Skip to content

Commit

Permalink
Continue to update alarms
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Jan 31, 2025
1 parent d8d6281 commit 3fb28f5
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion api/routes/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ export default async function router(schema: Schema, config: Config) {
This API allows a layer token to request the layer object and obtain the
connection ID for subsequent calls
`,
query: Type.Object({
alarms: Type.Boolean({
default: false,
description: 'Get Live Alarm state from CloudWatch'
}),
}),
params: Type.Object({
layerid: Type.Integer({ minimum: 1 }),
}),
Expand All @@ -164,8 +170,17 @@ export default async function router(schema: Schema, config: Config) {
return await config.models.Layer.augmented_from(req.params.layerid);
});

let status = 'unknown';
if (config.StackName !== 'test' && req.query.alarms) {
try {
status = await alarm.get(layer.id);
} catch (err) {
console.error(err);
}
}

res.json({
status: config.StackName !== 'test' ? await alarm.get(layer.id) : 'unknown',
status,
...layer
});
} catch (err) {
Expand Down

0 comments on commit 3fb28f5

Please sign in to comment.