Return 200 unless all fail

Signed-off-by: sblausten <sam@roadie.io>
This commit is contained in:
sblausten
2022-12-20 11:57:22 +01:00
parent 4d1094bef4
commit 138b37994a
@@ -124,9 +124,14 @@ export async function createRouter<
}
});
const results = await Promise.all(tasks);
if (errors.length > 0) {
const noResults =
results.length === 0 || results.flatMap(r => r.results).length === 0;
if (errors.length > 0 && noResults) {
return res.status(500).send({ errors, results });
}
if (errors.length > 0) {
return res.json({ errors, results });
}
return res.json(results);
});
} else {