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

@@ -92,15 +92,15 @@ export class OneboxSslManager {
/**
* Acquire certificate and return certificate data (for CertRequirementManager)
* Returns certificate paths and expiry information
* Returns certificate PEM content and expiry information
*/
async acquireCertificate(
domain: string,
includeWildcard = false
): Promise<{
certPath: string;
keyPath: string;
fullChainPath: string;
certPem: string;
keyPem: string;
fullchainPem: string;
expiryDate: number;
issuer: string;
}> {
@@ -122,8 +122,8 @@ export class OneboxSslManager {
// Reload certificates in reverse proxy
await this.oneboxRef.reverseProxy.reloadCertificates();
// The certManager stores the cert to disk and database during getCertificateForDomain
// Look up the paths from the database
// The certManager stores the cert to database during getCertificateForDomain
// Look up the PEM content from the database
const dbCert = this.database.getSSLCertificate(domain);
if (!dbCert) {
throw new Error(`Certificate stored but not found in database for ${domain}`);
@@ -131,11 +131,11 @@ export class OneboxSslManager {
// Return certificate data from database
return {
certPath: dbCert.certPath,
keyPath: dbCert.keyPath,
fullChainPath: dbCert.fullChainPath,
certPem: dbCert.certPem,
keyPem: dbCert.keyPem,
fullchainPem: dbCert.fullchainPem,
expiryDate: cert.validUntil,
issuer: dbCert.issuer || 'Let\'s Encrypt',
issuer: dbCert.issuer || "Let's Encrypt",
};
} catch (error) {
logger.error(`Failed to acquire certificate for ${domain}: ${getErrorMessage(error)}`);