Checkpoint

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/6ce2ae76-29c8-4e4f-a567-3016f632e118.jpg
This commit is contained in:
alphaeusmote
2025-04-11 02:20:10 +00:00
parent cfe0fc2862
commit 58c0ae2e61
+9 -6
View File
@@ -470,7 +470,10 @@ export class DatabaseStorage implements IStorage {
async createDnsRecord(record: InsertDnsRecord): Promise<DnsRecord> { async createDnsRecord(record: InsertDnsRecord): Promise<DnsRecord> {
try { try {
console.log("Creating DNS record with data:", record);
// Convert snake_case field names for database compatibility // Convert snake_case field names for database compatibility
// We don't need providerId as it's not in the db table
const { proxied, isAutoIP, providerId, ...validFields } = record as any; const { proxied, isAutoIP, providerId, ...validFields } = record as any;
// Create SQL query with proper parameterization using SQL template literals // Create SQL query with proper parameterization using SQL template literals
@@ -482,27 +485,28 @@ export class DatabaseStorage implements IStorage {
${validFields.domainId}, ${validFields.domainId},
${validFields.name}, ${validFields.name},
${validFields.type}, ${validFields.type},
${validFields.content}, ${validFields.content || ''},
${validFields.ttl || 3600}, ${validFields.ttl || 3600},
${validFields.priority || 0}, ${validFields.priority || 0},
${validFields.isActive !== undefined ? validFields.isActive : true}, ${validFields.isActive !== undefined ? validFields.isActive : true},
${isAutoIP !== undefined ? isAutoIP : false}, ${isAutoIP !== undefined ? isAutoIP : false},
${validFields.notes || null}, ${validFields.notes || null},
${new Date()}, ${new Date()},
${null} -- provider_record_id will be populated when syncing with providers ${validFields.providerRecordId || null}
) )
RETURNING id, domain_id, name, type, content, ttl, priority, RETURNING *
is_active, auto_update, notes, last_updated, created_at, provider_record_id
`; `;
// Execute the query directly with SQL template literal // Execute the query directly with SQL template literal
const result = await db.execute(queryText); const result = await db.execute(queryText);
if (!Array.isArray(result) || result.length === 0) { if (!Array.isArray(result) || result.length === 0) {
console.error("DNS record creation failed - empty result returned");
throw new Error("Failed to create DNS record"); throw new Error("Failed to create DNS record");
} }
const newRecord = result[0]; const newRecord = result[0];
console.log("New DNS record created:", newRecord);
// Return the record with frontend-expected field names // Return the record with frontend-expected field names
return { return {
@@ -519,8 +523,7 @@ export class DatabaseStorage implements IStorage {
lastUpdated: newRecord.last_updated, lastUpdated: newRecord.last_updated,
createdAt: newRecord.created_at, createdAt: newRecord.created_at,
providerRecordId: newRecord.provider_record_id, providerRecordId: newRecord.provider_record_id,
proxied: null, // Add missing fields with null values proxied: null // Maintained for frontend compatibility
providerId: null
}; };
} catch (error) { } catch (error) {
console.error("Error in createDnsRecord:", error); console.error("Error in createDnsRecord:", error);