feat: certificates, landing pages, ai tutor, website update, compliance
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { Hono } from '@api/utils/hono';
|
||||
import { apiKeyMiddleware } from '@api/middlewares/api-key';
|
||||
import { handleError } from '@api/utils/errors';
|
||||
import { runWorkspaceGraceCheck } from '@api/services/account';
|
||||
|
||||
export const internalAccountRouter = new Hono().post('/workspace-grace', apiKeyMiddleware, async (c) => {
|
||||
try {
|
||||
const data = await runWorkspaceGraceCheck();
|
||||
return c.json({ success: true, data }, 200);
|
||||
} catch (error) {
|
||||
return handleError(c, error, 'Failed to run workspace grace check');
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Hono } from '@api/utils/hono';
|
||||
import { apiKeyMiddleware } from '@api/middlewares/api-key';
|
||||
import { handleError } from '@api/utils/errors';
|
||||
import { runAnalyticsRollupDaily } from '@cio/analytics';
|
||||
|
||||
export const internalAnalyticsRouter = new Hono().post('/rollup-daily', apiKeyMiddleware, async (c) => {
|
||||
try {
|
||||
const daysAgoHeader = c.req.query('daysAgo');
|
||||
const daysAgo = daysAgoHeader ? Number(daysAgoHeader) : 1;
|
||||
const result = await runAnalyticsRollupDaily({
|
||||
daysAgo: Number.isFinite(daysAgo) && daysAgo > 0 ? daysAgo : 1
|
||||
});
|
||||
|
||||
return c.json({ success: true, data: result }, 200);
|
||||
} catch (error) {
|
||||
return handleError(c, error, 'Failed to run analytics rollup');
|
||||
}
|
||||
});
|
||||
@@ -1,4 +1,5 @@
|
||||
import { runComplianceExpiryCheck, runComplianceReminderScan } from '@api/services/course/compliance';
|
||||
import { runProgramGoalEvaluationSweep, runProgramGoalReminderScan } from '@api/services/program/goal';
|
||||
|
||||
import { Hono } from '@api/utils/hono';
|
||||
import { apiKeyMiddleware } from '@api/middlewares/api-key';
|
||||
@@ -34,4 +35,32 @@ export const internalComplianceRouter = new Hono()
|
||||
} catch (error) {
|
||||
return handleError(c, error, 'Failed to run compliance reminder scan');
|
||||
}
|
||||
})
|
||||
/**
|
||||
* POST /internal/compliance/evaluate-program-goals
|
||||
* Daily sweep: re-evaluate every active program goal and refresh per-learner
|
||||
* `program_goal_assignment` rows.
|
||||
*/
|
||||
.post('/evaluate-program-goals', apiKeyMiddleware, async (c) => {
|
||||
try {
|
||||
const data = await runProgramGoalEvaluationSweep();
|
||||
|
||||
return c.json({ success: true, data }, 200);
|
||||
} catch (error) {
|
||||
return handleError(c, error, 'Failed to run program goal evaluation sweep');
|
||||
}
|
||||
})
|
||||
/**
|
||||
* POST /internal/compliance/send-program-goal-reminders
|
||||
* Sends learner reminder emails for upcoming/overdue program goals using
|
||||
* each goal's `reminderDaysBefore` cadence.
|
||||
*/
|
||||
.post('/send-program-goal-reminders', apiKeyMiddleware, async (c) => {
|
||||
try {
|
||||
const data = await runProgramGoalReminderScan();
|
||||
|
||||
return c.json({ success: true, data }, 200);
|
||||
} catch (error) {
|
||||
return handleError(c, error, 'Failed to run program goal reminder scan');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Hono } from '@api/utils/hono';
|
||||
import { internalAccountRouter } from './account';
|
||||
import { internalAnalyticsRouter } from './analytics';
|
||||
import { internalComplianceRouter } from './compliance';
|
||||
|
||||
export const internalRouter = new Hono()
|
||||
.route('/compliance', internalComplianceRouter)
|
||||
.route('/analytics', internalAnalyticsRouter)
|
||||
.route('/account', internalAccountRouter);
|
||||
Reference in New Issue
Block a user