Strongly type invokeHook

Add strong typing of the invokeHook function to prevent incorrect
paramaters being passed to plugin hooks. This detected a few places
where the parameters passed were incorrect.
This commit is contained in:
Hornwitser committed 2023-11-28 14:28:22 +01:00
1 parent e3e5867d60
commit 654df76065
7 files changed
+24 -18

No files matched your search

+1 -2
View File
@@ -37,8 +37,7 @@ async function getMetrics(req: Request, res: Response, next: any) {
const controller: Controller = req.app.locals.controller;
let results: lib.CollectorResult[] = [];
type ResultIterator = AsyncIterable<lib.CollectorResult> | Iterable<lib.CollectorResult>
let pluginResults = await lib.invokeHook(controller.plugins, "onMetrics") as ResultIterator[];
let pluginResults = await lib.invokeHook(controller.plugins, "onMetrics");
for (let metricIterator of pluginResults) {
for await (let metric of metricIterator) {
results.push(metric);