addition of new dashboard

This commit is contained in:
2026-08-20 15:08:32 +00:00
parent 0622018d95
commit bf59249ed7
161 changed files with 13170 additions and 119 deletions

14
backend/common/http.js Normal file
View File

@@ -0,0 +1,14 @@
export const fail = (res, status, code, message) =>
res.status(status).json({ error: { code, message } });
// Requires a logged-in user (401) and turns a throw into a 500 envelope, so a
// data-layer failure never masquerades as empty-but-200 data.
export const sessionRoute = (label, fn) => async (req, res) => {
if (!req.user) return fail(res, 401, "unauthorized", "Not logged in");
try {
await fn(req, res);
} catch (e) {
console.error(`${label} ${req.method} ${req.path}:`, e);
fail(res, 500, "internal", "Internal error");
}
};