Link K8S deps properly

This commit is contained in:
Elijah Dunemask 2022-10-08 17:47:46 +00:00
parent 0ac77cdb15
commit f0260fc819
64 changed files with 4282 additions and 3069 deletions

View file

@ -1,5 +1,9 @@
import { Router, json as jsonMiddleware } from "express";
import { getSilencedTests } from "../database/queries/alerting.js";
import {
getSilencedTests,
upsertAlertSilence,
deleteAlertSilence,
} from "../database/queries/alerting.js";
const router = Router();
// Apply Middlewares
@ -12,7 +16,26 @@ router.get("/silenced", (req, res) => {
// Post Routes
router.post("/silence", (req, res) => {
res.sendStatus(200);
const { name, class: className, method, expires, keepExpires } = req.body;
if (!name || !className || !method)
return res
.status(400)
.send("'name', 'class', and 'method' are all required Fields!");
if (expires === null)
return deleteAlertSilence(req.body)
.then(() => res.sendStatus(200))
.catch((e) => res.status(500).send(e));
const { h, m } = keepExpires ? {} : expires;
if (!keepExpires && (h == null || m == null))
return res.status(400).send("Both 'h' and 'm' are required fields!");
if (!keepExpires && (h < 0 || m < 0))
return res
.status(400)
.send("'h' and 'm' must be greater than or equal to 0!");
// TODO set max times as well
if (!keepExpires && (h > 72 || m > 59))
res.status(400).send("'h' and 'm' must not exceed the set maxes!");
upsertAlertSilence(req.body).then(() => res.sendStatus(200));
});
export default router;

View file

@ -1,5 +1,9 @@
import { Router, json as jsonMiddleware } from "express";
import { getTests, getPipelineMappings } from "../database/queries/catalog.js";
import {
getTests,
getPipelineMappings,
upsertTest,
} from "../database/queries/catalog.js";
const router = Router();
const maxSize = 1024 * 1024 * 100; // 100MB
@ -18,8 +22,10 @@ router.get("/pipeline-mappings", (req, res) => {
// Post Routes
router.post("/update", (req, res) => {
// Update All Tests
res.sendStatus(200);
if (!req.body) return res.status(400).send("Body required!");
if(!Array.isArray(req.body)) return res.status(400).send("Body must be an array!");
const upserts = Promise.all(req.body.map((catalogItem)=>upsertTest(catalogItem)));
upserts.then(()=>res.sendStatus(200)).catch((e)=>res.status(500).send(e));
});
export default router;

View file

@ -1,5 +1,8 @@
import { Router, json as jsonMiddleware } from "express";
import { getCurrentlyFailing } from "../database/queries/results.js";
import {
getCurrentlyFailing,
ignoreResult,
} from "../database/queries/results.js";
const router = Router();
// Apply Middlewares
@ -15,4 +18,10 @@ router.post("/history", (req, res) => {
res.send([]);
});
router.post("/ignore", (req, res) => {
if (!req.body || !req.body.id)
return res.status(400).send("'id' is required!");
ignoreResult(req.body).then(() => res.sendStatus(200));
});
export default router;

View file

@ -2,6 +2,7 @@
import express from "express";
// Routes
import vitals from "../routes/vitals-route.js";
import results from "../routes/results-route.js";
import alerting from "../routes/alerting-route.js";
import react from "../routes/react-route.js";
@ -12,6 +13,7 @@ import buildDevRoute from "../routes/dev-route.js";
export default function buildRoutes(pg, skio) {
const router = express.Router();
// Special Routes
router.use(vitals);
router.all("/", (req, res) => res.redirect("/qualiteer"));
if (process.env.USE_DEV_ROUTER === "true")
router.use("/api/dev", buildDevRoute(pg, skio));

View file

@ -0,0 +1,7 @@
import { Router } from "express";
const router = Router();
// Get Routes
router.get("/healthz", (req, res) => res.sendStatus(200));
export default router;