Code quality improvements from code review

- Add admin-only authorization for company and projects CRUD operations
- Create requireAccountId middleware to eliminate code duplication
- Standardize error handling (use next(error) consistently)
- Change error messages to Slovak language

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
richardtekula
2025-12-05 11:03:32 +01:00
parent 03b7a215bb
commit 6f4a31e9de
19 changed files with 186 additions and 191 deletions

View File

@@ -20,7 +20,7 @@ export const getAllCompanies = async (req, res, next) => {
data: companies,
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -39,7 +39,7 @@ export const getCompanyById = async (req, res, next) => {
data: company,
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -62,7 +62,7 @@ export const getCompanyEmailThreads = async (req, res, next) => {
data: result,
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -80,7 +80,7 @@ export const getCompanyUnreadCounts = async (req, res, next) => {
data: counts,
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -99,7 +99,7 @@ export const getCompanyWithRelations = async (req, res, next) => {
data: company,
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -124,7 +124,7 @@ export const createCompany = async (req, res, next) => {
message: 'Firma bola vytvorená',
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -146,7 +146,7 @@ export const updateCompany = async (req, res, next) => {
message: 'Firma bola aktualizovaná',
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -173,7 +173,7 @@ export const deleteCompany = async (req, res, next) => {
message: result.message,
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -193,7 +193,7 @@ export const getCompanyNotes = async (req, res, next) => {
data: notes,
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -218,7 +218,7 @@ export const addCompanyNote = async (req, res, next) => {
message: 'Poznámka bola pridaná',
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -241,7 +241,7 @@ export const updateCompanyNote = async (req, res, next) => {
message: 'Poznámka bola aktualizovaná',
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -260,7 +260,7 @@ export const deleteCompanyNote = async (req, res, next) => {
message: result.message,
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -280,7 +280,7 @@ export const getCompanyReminders = async (req, res, next) => {
data: reminders,
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -297,7 +297,7 @@ export const createCompanyReminder = async (req, res, next) => {
message: 'Reminder bol pridaný',
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -314,7 +314,7 @@ export const updateCompanyReminder = async (req, res, next) => {
message: 'Reminder bol aktualizovaný',
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -329,7 +329,7 @@ export const deleteCompanyReminder = async (req, res, next) => {
message: result.message,
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -341,7 +341,7 @@ export const getReminderSummary = async (_req, res, next) => {
data: summary,
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -353,7 +353,7 @@ export const getReminderCountsByCompany = async (_req, res, next) => {
data: counts,
});
} catch (error) {
return next(error);
next(error);
}
};
@@ -366,6 +366,6 @@ export const getUpcomingReminders = async (_req, res, next) => {
data: reminders,
});
} catch (error) {
return next(error);
next(error);
}
};