mirror of
https://github.com/alexgo-io/redstone-cache-layer.git
synced 2026-04-30 20:52:07 +08:00
21 lines
561 B
TypeScript
21 lines
561 B
TypeScript
import { Router } from "express";
|
|
import asyncHandler from "express-async-handler";
|
|
import { saveMetric } from "../helpers/cloudwatch";
|
|
|
|
export const metrics = (router: Router) => {
|
|
|
|
/**
|
|
* This endpoint is used for saving metric values in AWS Cloudwatch.
|
|
* Thanks to them we can analyse redstone-node performance and build
|
|
* nice charts
|
|
*/
|
|
router.post("/metrics", asyncHandler(async (req, res) => {
|
|
const { label, value } = req.body;
|
|
await saveMetric({ label, value });
|
|
|
|
return res.json({
|
|
msg: "Metric saved",
|
|
});
|
|
}));
|
|
};
|