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,87 @@
// /components/activityLogs/activityLogModel.js
'use strict';
const mongoose = require('mongoose');
const ACTIVITY_ACTIONS = [
'create',
'update',
'delete',
'login',
'logout',
'enroll',
'attendance',
'upload',
'retry',
'other'
];
const activityLogSchema = new mongoose.Schema(
{
actor: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
default: null,
index: true
},
actorUsername: {
type: String,
default: null,
index: true
},
actorName: {
type: String,
default: null
},
action: {
type: String,
enum: ACTIVITY_ACTIONS,
required: true,
index: true
},
resource: {
type: String,
required: true,
index: true
},
resourceId: {
type: String,
default: null
},
method: {
type: String,
required: true
},
path: {
type: String,
required: true
},
statusCode: {
type: Number,
default: null
},
ip: {
type: String,
default: null
},
userAgent: {
type: String,
default: null
},
description: {
type: String,
default: ''
},
metadata: {
type: mongoose.Schema.Types.Mixed,
default: {}
}
},
{ timestamps: true }
);
activityLogSchema.index({ createdAt: -1 });
activityLogSchema.index({ action: 1, createdAt: -1 });
module.exports = mongoose.model('ActivityLog', activityLogSchema);
module.exports.ACTIVITY_ACTIONS = ACTIVITY_ACTIONS;