feat: enhance API and middleware functionality: add public API routes, implement program and course member checks, and improve rate limiting for invite acceptance. Update OpenAPI spec generation to focus on public API endpoints and add new middleware for automation key scopes. Include new documentation for lesson AI features and public API tests.

This commit is contained in:
Rotimi Best
2026-04-12 08:58:41 +01:00
parent 5a8f50f67b
commit d6e812d08b
573 changed files with 31964 additions and 8708 deletions
@@ -0,0 +1,36 @@
/** Backend error JSON from API `handleError` responses (also carried as thrown `ApiError.message` on 4xx). */
export type ApiErrorBody = {
success: false;
error: string;
code: string;
field?: string;
};
/**
* Parses `this.error` / ApiError.message when the API returned a JSON body with `success: false`.
*/
export function tryParseApiErrorBody(raw: string | null | undefined): ApiErrorBody | null {
if (!raw?.trim()) {
return null;
}
try {
const parsed = JSON.parse(raw) as unknown;
if (
typeof parsed === 'object' &&
parsed !== null &&
'success' in parsed &&
(parsed as { success: unknown }).success === false &&
'code' in parsed &&
typeof (parsed as { code: unknown }).code === 'string' &&
'error' in parsed &&
typeof (parsed as { error: unknown }).error === 'string'
) {
return parsed as ApiErrorBody;
}
} catch {
// not JSON
}
return null;
}