Eliminate all mock fallbacks in Docs and Drive endpoints with real local file generators

This commit is contained in:
2026-07-22 19:42:35 -04:00
parent 6ba84ba37e
commit c17b82d1e3
2 changed files with 43 additions and 10 deletions
+19 -8
View File
@@ -689,12 +689,18 @@ app.post("/api/workspace/docs/create", async (req, res) => {
});
}
const mockId = `doc_${Date.now()}_${Math.random().toString(36).substring(2, 6)}`;
// Local downloadable Document package generator when running without live Google OAuth access token
const docTitle = title || `Tailored ${docType === 'coverLetter' ? 'Cover Letter' : 'Resume'}`;
const htmlContent = `<!DOCTYPE html><html><head><meta charset="utf-8"><title>${docTitle}</title><style>body{font-family:Arial,sans-serif;line-height:1.6;padding:40px;max-width:800px;margin:0 auto;color:#111;}h1{border-bottom:2px solid #333;padding-bottom:10px;}pre{white-space:pre-wrap;font-family:inherit;}</style></head><body><h1>${docTitle}</h1><pre>${content || ''}</pre></body></html>`;
const base64Doc = Buffer.from(htmlContent).toString('base64');
const downloadUrl = `data:text/html;charset=utf-8;base64,${base64Doc}`;
res.json({
success: true,
documentId: mockId,
documentUrl: `https://docs.google.com/document/d/${mockId}/edit`,
message: `Google Doc prepared for ${title}`
documentId: `local_doc_${Date.now()}`,
documentUrl: downloadUrl,
isLocalDoc: true,
message: `Created downloadable Document package for ${docTitle}!`
});
} catch (error: any) {
console.error("Google Docs Creation Error:", error);
@@ -734,12 +740,17 @@ app.post("/api/workspace/drive/upload", async (req, res) => {
});
}
const mockId = `drive_${Date.now()}_${Math.random().toString(36).substring(2, 6)}`;
// Local downloadable artifact file generator when running without live Google OAuth access token
const safeFileName = fileName || `Job_Artifact_${Date.now()}.txt`;
const base64File = Buffer.from(fileContent || '').toString('base64');
const downloadUrl = `data:${mimeType || 'text/plain'};base64,${base64File}`;
res.json({
success: true,
fileId: mockId,
driveUrl: `https://drive.google.com/file/d/${mockId}/view`,
message: `File saved to Google Drive workspace folder.`
fileId: `local_file_${Date.now()}`,
driveUrl: downloadUrl,
isLocalFile: true,
message: `Saved ${safeFileName} to local workspace storage!`
});
} catch (error: any) {
console.error("Google Drive Upload Error:", error);