-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
55 lines (48 loc) · 2.05 KB
/
test.js
File metadata and controls
55 lines (48 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import fs from 'fs';
import path from 'path';
const API_URL = 'http://localhost:3000';
const USERNAME = 'minersBeaver';
const PASSWORD = '1234qwer';
const JD_FILE = 'C:/Users/miner/Downloads/Senior Research Scientist, Sustainability, WW Sustainability.docx';
const RESUME_FILE = 'C:/Users/miner/Downloads/Jane_Resume.docx';
function toBase64(filePath) {
const buf = fs.readFileSync(filePath);
const mime = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
return `data:${mime};base64,${buf.toString('base64')}`;
}
async function run() {
// 1. Login
console.log('Logging in…');
const loginRes = await fetch(`${API_URL}/auth/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: USERNAME, password: PASSWORD }),
});
const { token, error: loginErr } = await loginRes.json();
if (!token) { console.error('Login failed:', loginErr); process.exit(1); }
console.log('Logged in.');
// 2. Evaluate
console.log('Sending files for evaluation…');
const evalRes = await fetch(`${API_URL}/evaluate`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
body: JSON.stringify({
jdFile: toBase64(JD_FILE),
resumeFile: toBase64(RESUME_FILE),
}),
});
const result = await evalRes.json();
if (!evalRes.ok) { console.error('Evaluation failed:', result); process.exit(1); }
// 3. Print results
console.log('\n=== RESULTS ===');
console.log(`Score: ${result.score}/100`);
console.log(`\nPresent skills (${result.presentSkills?.length}):`);
result.presentSkills?.forEach(s => console.log(` ✓ ${s}`));
console.log(`\nMissing skills (${result.missingSkills?.length}):`);
result.missingSkills?.forEach(s => console.log(` ✗ ${s}`));
console.log(`\nSuggestions:`);
result.suggestions?.forEach((s, i) => console.log(` ${i + 1}. ${s}`));
console.log('\nFull JSON saved to test-result.json');
fs.writeFileSync('test-result.json', JSON.stringify(result, null, 2));
}
run().catch(console.error);