-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-endpoints.js
More file actions
35 lines (29 loc) · 1.09 KB
/
test-endpoints.js
File metadata and controls
35 lines (29 loc) · 1.09 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
const axios = require('axios');
const BASE_URL = 'http://localhost:8800';
const TEST_HANDLE = 'vamsi_789'; // Example handle
const testEndpoint = async (path) => {
console.log(`Testing ${path}...`);
try {
const response = await axios.get(`${BASE_URL}${path}`);
console.log(`✅ ${path}: SUCCESS (${response.status})`);
// Print a snippet of the response data
const dataPreview = JSON.stringify(response.data).substring(0, 100);
console.log(` Data: ${dataPreview}...`);
} catch (err) {
console.error(`❌ ${path}: FAILED (${err.response?.status || err.message})`);
if (err.response) {
console.error(` Error Data:`, err.response.data);
}
}
};
const runTests = async () => {
console.log('🚀 Starting API tests...');
await testEndpoint('/health');
await testEndpoint(`/api/profile/${TEST_HANDLE}`);
await testEndpoint(`/api/ratings/${TEST_HANDLE}`);
await testEndpoint(`/api/recent/${TEST_HANDLE}`);
await testEndpoint('/api/upcoming');
await testEndpoint(`/api/whole/${TEST_HANDLE}`);
console.log('🏁 All tests completed.');
};
runTests();