-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver-test.js
More file actions
36 lines (30 loc) · 1.02 KB
/
server-test.js
File metadata and controls
36 lines (30 loc) · 1.02 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
/**
* Simple test script to check if the Express server is working correctly
*/
import fetch from 'node-fetch';
// Test the API
async function testAPI() {
try {
console.log('Testing API connection...');
// Test the test endpoint
const testResponse = await fetch('http://localhost:3001/api/test');
const testData = await testResponse.text();
console.log('Test endpoint response:', testResponse.status, testData);
// Test signup endpoint
const signupResponse = await fetch('http://localhost:3001/api/signup', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
username: 'testuser',
email: 'test@example.com',
password: 'password123'
})
});
const signupData = await signupResponse.text();
console.log('Signup endpoint response:', signupResponse.status, signupData);
console.log('API tests completed.');
} catch (error) {
console.error('API test failed:', error);
}
}
testAPI();