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
@@ -0,0 +1,45 @@
// /components/certificates/certificateController.js
const catchAsync = require('../../utils/catchAsync');
const certificateService = require('./certificateService');
const { successResponse, listResponse } = require('../../utils/apiResponse');
exports.create = catchAsync(async (req, res, next) => {
const certificate = await certificateService.createCertificate(req.body);
return successResponse(res, 201, 'Certificate created successfully', certificate);
});
exports.getOne = catchAsync(async (req, res, next) => {
const certificate = await certificateService.getCertificateById(req.params.id);
return successResponse(res, 200, 'Certificate retrieved successfully', certificate);
});
exports.getAll = catchAsync(async (req, res, next) => {
const { data, meta } = await certificateService.getAllCertificates(req.query);
return listResponse(res, 200, data, meta);
});
exports.update = catchAsync(async (req, res, next) => {
const certificate = await certificateService.updateCertificate(req.params.id, req.body);
return successResponse(res, 200, 'Certificate updated successfully', certificate);
});
exports.delete = catchAsync(async (req, res, next) => {
await certificateService.deleteCertificate(req.params.id);
return successResponse(res, 200, 'Certificate deleted successfully');
});
exports.search = catchAsync(async (req, res, next) => {
const { data, meta } = await certificateService.searchCertificates(req.query);
return listResponse(res, 200, data, meta);
});
exports.upload = catchAsync(async (req, res, next) => {
const certificate = await certificateService.uploadUserCertificate(req.user._id, req.body);
return successResponse(res, 201, 'Certificate uploaded and committed successfully', certificate);
});
exports.getMyCertificates = catchAsync(async (req, res, next) => {
const { data, meta } = await certificateService.getMyCertificates(req.user._id, req.query);
return listResponse(res, 200, data, meta);
});