Initial commit: teaching institution management API.

Express/MongoDB backend with JWT auth, RBAC, S3 uploads, notifications, and scheduled jobs.
This commit is contained in:
2026-08-09 04:18:08 +02:00
commit f04c797be6
107 changed files with 9190 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
// /utils/apiResponse.js
const successResponse = (res, statusCode = 200, message = 'Operation successful', data = null) => {
const response = {
success: true,
message
};
if (data !== null) {
response.data = data;
}
return res.status(statusCode).json(response);
};
const listResponse = (res, statusCode = 200, data = [], meta = {}) => {
return res.status(statusCode).json({
success: true,
data,
meta: {
totalCount: meta.totalCount || 0,
totalPages: meta.totalPages || 0,
currentPage: meta.currentPage || 1,
limit: meta.limit || 20
}
});
};
const errorResponse = (res, statusCode = 500, code = 'INTERNAL_SERVER_ERROR', message = 'An error occurred', details = {}) => {
return res.status(statusCode).json({
success: false,
error: {
code,
message,
details: details || {}
}
});
};
module.exports = {
successResponse,
listResponse,
errorResponse
};