Fix codecheck -> Handle all nullish things possible

This commit is contained in:
Leon Meier 2025-03-02 18:52:35 +01:00
parent bca596fa75
commit 5ab2df351c
2 changed files with 5 additions and 3 deletions

View File

@ -39,7 +39,7 @@ async function get(req: Request, res: Response) {
if (result.length !== 0) {
result.forEach((element: { id: number; name: string; code: string | null | boolean }) => {
// code-> true if code is set
element.code = element.code !== '';
element.code = !(element.code === '' || element.code === null || element.code === undefined); // Check if nullish
});
res.status(200).json({ count, result });
} else {
@ -69,7 +69,9 @@ async function get(req: Request, res: Response) {
if (result.length !== 0) {
result.forEach((element: { id: number; name: string; code: string | null | boolean }) => {
// code-> true if code is set
element.code = element.code !== '';
//log.api?.debug('"' + element.code + '"');
//log.api?.debug(!(element.code === ''), !(element.code === null), !(element.code === undefined));
element.code = !(element.code === '' || element.code === null || element.code === undefined); // Check if nullish
});
res.status(200).json({ count, result });
} else {

View File

@ -27,7 +27,7 @@ async function get(req: Request, res: Response) {
// result?.code === null -> user exists and has no code
// result?.code === undefined -> user does not exists
// value.code === result?.code -> If user exists and has no code this matches
res.status(200).json(result?.code === '' || result?.code === null || result?.code === undefined || value.code === result?.code);
res.status(200).json(result?.code === '' || result?.code === null || result?.code === undefined || result?.code === value.code);
//log.api?.debug(result, result?.code);
});
}