forked from Shreyas765/RefNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_mastra_backend.js
More file actions
68 lines (61 loc) · 2.05 KB
/
test_mastra_backend.js
File metadata and controls
68 lines (61 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
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env node
// Test script for Mastra backend
const testMastraBackend = async () => {
console.log('🧪 Testing Mastra Backend');
console.log('========================');
try {
// Test the health endpoint
const healthResponse = await fetch('http://localhost:4111/health');
if (healthResponse.ok) {
const health = await healthResponse.json();
console.log('✅ Mastra backend is running');
console.log('📊 Health status:', health);
} else {
throw new Error(`Health check failed: ${healthResponse.status}`);
}
// Test the chat endpoint
const chatResponse = await fetch('http://localhost:4111/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
prompt: 'What do you know about these papers?',
additionalContext: {
selectedPapers: [
{
title: 'Test Paper 1',
authors: ['John Doe'],
year: 2023,
citations: 50,
topics: ['AI', 'Machine Learning'],
abstract: 'This is a test paper about artificial intelligence and machine learning applications.'
}
],
graphData: {
totalNodes: 1,
totalLinks: 0
}
}
})
});
if (chatResponse.ok) {
const chatResult = await chatResponse.json();
console.log('✅ Chat endpoint working');
console.log('💬 Response preview:', chatResult.content?.substring(0, 200) + '...');
} else {
throw new Error(`Chat test failed: ${chatResponse.status}`);
}
console.log('\n🎉 Mastra backend test completed successfully!');
return true;
} catch (error) {
console.error('❌ Mastra backend test failed:', error.message);
console.log('\n💡 Make sure to start the Mastra backend first:');
console.log(' cd mastra-backend && npm start');
return false;
}
};
// Run the test
testMastraBackend().then(success => {
process.exit(success ? 0 : 1);
});