From e5293fc82afb09bd47fc6d3983b52b14199cfa37 Mon Sep 17 00:00:00 2001 From: DaKheera47 Date: Tue, 20 Jan 2026 12:12:25 +0000 Subject: [PATCH] listing resume in settings using service correctly --- .../src/server/api/routes/settings.ts | 26 ++----------------- orchestrator/src/server/services/rxresume.ts | 10 +++++-- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/orchestrator/src/server/api/routes/settings.ts b/orchestrator/src/server/api/routes/settings.ts index eb7dda8..1d0bb4f 100644 --- a/orchestrator/src/server/api/routes/settings.ts +++ b/orchestrator/src/server/api/routes/settings.ts @@ -7,6 +7,7 @@ import { normalizeResumeProjectsSettings, resolveResumeProjectsSettings, } from '../../services/resumeProjects.js'; +import { listResumes } from '../../services/rxresume.js'; export const settingsRouter = Router(); @@ -299,30 +300,7 @@ settingsRouter.patch('/', async (req: Request, res: Response) => { */ settingsRouter.get('/rx-resumes', async (_req: Request, res: Response) => { try { - const apiKey = process.env.RXRESUME_API_KEY; - if (!apiKey) { - return res.status(400).json({ success: false, error: 'RXRESUME_API_KEY not configured in environment' }); - } - - const baseUrl = process.env.RXRESUME_URL || 'https://rxresu.me'; - // Remove trailing slash if present - const cleanBaseUrl = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl; - - console.log(`🔍 Fetching resumes from Reactive Resume at ${cleanBaseUrl}/api/resume...`); - - const response = await fetch(`${cleanBaseUrl}/api/resume`, { - headers: { - 'x-api-key': apiKey, - 'Content-Type': 'application/json', - }, - }); - - if (!response.ok) { - const errorData = await response.json().catch(() => ({ message: response.statusText })); - throw new Error(`Reactive Resume API error (${response.status}): ${errorData.message || response.statusText}`); - } - - const resumes = await response.json(); + const resumes = await listResumes(); res.json({ success: true, resumes }); } catch (error) { const message = error instanceof Error ? error.message : 'Unknown error'; diff --git a/orchestrator/src/server/services/rxresume.ts b/orchestrator/src/server/services/rxresume.ts index ba0560f..6286a87 100644 --- a/orchestrator/src/server/services/rxresume.ts +++ b/orchestrator/src/server/services/rxresume.ts @@ -22,8 +22,8 @@ export async function fetchRxResume(path: string, options: RequestInit = {}): Pr const baseUrl = process.env.RXRESUME_URL || 'https://rxresu.me'; const cleanBaseUrl = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl; - // The API endpoints are at /api/* - const url = `${cleanBaseUrl}/api${path}`; + // The API endpoints are at /api/openapi/* + const url = `${cleanBaseUrl}/api/openapi${path}`; const headers = { 'x-api-key': apiKey, @@ -83,3 +83,9 @@ export async function exportResumePdf(id: string): Promise { const result = await fetchRxResume(`/printer/resume/${id}/pdf`); return result.url; } +/** + * List all resumes. + */ +export async function listResumes(): Promise<{ id: string; name: string }[]> { + return fetchRxResume('/resume'); +}