refactor: migrate services from app.config to unified config
- Update email verification template to use unifiedConfig - Update ProductionDatabaseStrategy to use databaseConfig from unified config - Update mailgun service to use unifiedConfig for baseUrl - Provides consistent configuration access across all services - Part of migration to single source of truth configuration system
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
import { EmailVerificationToken } from '../auth.types';
|
import { EmailVerificationToken } from '../auth.types';
|
||||||
import { appConfig } from '../../../config/app.config';
|
import { unifiedConfig } from '../../../config/unified.config';
|
||||||
|
|
||||||
export const verificationEmailTemplate = (token: EmailVerificationToken) => {
|
export const verificationEmailTemplate = (token: EmailVerificationToken) => {
|
||||||
const verificationLink = `${appConfig.baseUrl}/verify-email?token=${token.token}`;
|
const verificationLink = `${unifiedConfig.app.baseUrl}/verify-email?token=${token.token}`;
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<html>
|
<html>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
} from '../../types';
|
} from '../../types';
|
||||||
import { AccountStatus } from '../auth/auth.constants';
|
import { AccountStatus } from '../auth/auth.constants';
|
||||||
import { DatabaseStrategy, DatabaseError } from './types';
|
import { DatabaseStrategy, DatabaseError } from './types';
|
||||||
import { getDatabaseConfig } from '../../config/app.config';
|
import { databaseConfig } from '../../config/unified.config';
|
||||||
import { logger } from '../logging';
|
import { logger } from '../logging';
|
||||||
|
|
||||||
export class ProductionDatabaseStrategy implements DatabaseStrategy {
|
export class ProductionDatabaseStrategy implements DatabaseStrategy {
|
||||||
@@ -18,8 +18,8 @@ export class ProductionDatabaseStrategy implements DatabaseStrategy {
|
|||||||
private auth: string;
|
private auth: string;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
// Get CouchDB configuration from centralized config
|
// Get CouchDB configuration from unified config
|
||||||
const dbConfig = getDatabaseConfig();
|
const dbConfig = databaseConfig;
|
||||||
|
|
||||||
this.baseUrl = dbConfig.url;
|
this.baseUrl = dbConfig.url;
|
||||||
this.auth = btoa(`${dbConfig.username}:${dbConfig.password}`);
|
this.auth = btoa(`${dbConfig.username}:${dbConfig.password}`);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { getMailgunConfig, type MailgunConfig } from './mailgun.config';
|
import { getMailgunConfig, type MailgunConfig } from './mailgun.config';
|
||||||
import { appConfig } from '../config/app.config';
|
import { unifiedConfig } from '../config/unified.config';
|
||||||
|
|
||||||
interface EmailTemplate {
|
interface EmailTemplate {
|
||||||
subject: string;
|
subject: string;
|
||||||
@@ -139,13 +139,13 @@ export class MailgunService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async sendVerificationEmail(email: string, token: string): Promise<boolean> {
|
async sendVerificationEmail(email: string, token: string): Promise<boolean> {
|
||||||
const verificationUrl = `${appConfig.baseUrl}/verify-email?token=${token}`;
|
const verificationUrl = `${unifiedConfig.app.baseUrl}/verify-email?token=${token}`;
|
||||||
const template = this.getVerificationEmailTemplate(verificationUrl);
|
const template = this.getVerificationEmailTemplate(verificationUrl);
|
||||||
return this.sendEmail(email, template);
|
return this.sendEmail(email, template);
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendPasswordResetEmail(email: string, token: string): Promise<boolean> {
|
async sendPasswordResetEmail(email: string, token: string): Promise<boolean> {
|
||||||
const resetUrl = `${appConfig.baseUrl}/reset-password?token=${token}`;
|
const resetUrl = `${unifiedConfig.app.baseUrl}/reset-password?token=${token}`;
|
||||||
const template = this.getPasswordResetEmailTemplate(resetUrl);
|
const template = this.getPasswordResetEmailTemplate(resetUrl);
|
||||||
return this.sendEmail(email, template);
|
return this.sendEmail(email, template);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user