feat: Implement repositories for authentication, certificates, metrics, and platform services

- Added AuthRepository for user and settings management with CRUD operations.
- Introduced CertificateRepository to handle domains, certificates, and requirements.
- Created MetricsRepository for managing metrics and logs.
- Developed PlatformRepository for platform services and resources management.
- Established RegistryRepository for registry and token operations.
- Implemented ServiceRepository for CRUD operations on services.
- Defined types and interfaces in types.ts for database interactions.
This commit is contained in:
2025-11-25 23:27:27 +00:00
parent 9d58971983
commit ad89f2cc1f
18 changed files with 2249 additions and 1966 deletions

View File

@@ -152,9 +152,9 @@ export class CertRequirementManager {
domainId: domain.id!,
certDomain: domain.domain,
isWildcard: useWildcard,
certPath: certData.certPath,
keyPath: certData.keyPath,
fullChainPath: certData.fullChainPath,
certPem: certData.certPem,
keyPem: certData.keyPem,
fullchainPem: certData.fullchainPem,
expiryDate: certData.expiryDate,
issuer: certData.issuer,
isValid: true,
@@ -239,9 +239,9 @@ export class CertRequirementManager {
// Update certificate in database
this.database.updateCertificate(cert.id!, {
certPath: certData.certPath,
keyPath: certData.keyPath,
fullChainPath: certData.fullChainPath,
certPem: certData.certPem,
keyPem: certData.keyPem,
fullchainPem: certData.fullchainPem,
expiryDate: certData.expiryDate,
issuer: certData.issuer,
});
@@ -260,7 +260,7 @@ export class CertRequirementManager {
/**
* Clean up old invalid certificates (90+ days old)
*/
async cleanupOldCertificates(): Promise<void> {
cleanupOldCertificates(): void {
try {
const allCertificates = this.database.getAllCertificates();
const now = Date.now();
@@ -272,18 +272,7 @@ export class CertRequirementManager {
// Check if certificate has been invalid for 90+ days
const timeSinceExpiry = now - cert.expiryDate;
if (timeSinceExpiry >= this.CLEANUP_DELAY_MS) {
// Delete certificate files
try {
await Deno.remove(cert.certPath);
await Deno.remove(cert.keyPath);
await Deno.remove(cert.fullChainPath);
} catch (error) {
logger.debug(
`Failed to delete certificate files for ${cert.certDomain}: ${getErrorMessage(error)}`
);
}
// Delete from database
// Delete from database (PEM content is stored in DB, no files to delete)
this.database.deleteCertificate(cert.id!);
deletedCount++;
logger.info(