UNPKG

realtimecursor

Version:

Real-time collaboration system with cursor tracking and approval workflow

48 lines (37 loc) โ€ข 1.61 kB
#!/usr/bin/env node const axios = require('axios'); const BASE_URL = 'http://localhost:3000'; async function testEndpoints() { console.log('๐Ÿงช Testing API Endpoints...\n'); try { // Test health endpoint console.log('1. Testing health endpoint...'); const healthResponse = await axios.get(`${BASE_URL}/health`); console.log('โœ… Health check:', healthResponse.data); // Test login console.log('\n2. Testing admin login...'); const loginResponse = await axios.post(`${BASE_URL}/auth/login`, { email: 'admin@example.com', password: 'Admin123!' }); const token = loginResponse.data.token; const headers = { Authorization: `Bearer ${token}` }; console.log('โœ… Admin login successful'); // Test projects endpoint console.log('\n3. Testing projects endpoint...'); const projectsResponse = await axios.get(`${BASE_URL}/projects`, { headers }); console.log('โœ… Projects endpoint working:', projectsResponse.data); // Test invitations endpoint console.log('\n4. Testing invitations endpoint...'); const invitationsResponse = await axios.get(`${BASE_URL}/invitations`, { headers }); console.log('โœ… Invitations endpoint working:', invitationsResponse.data); console.log('\n๐ŸŽ‰ All endpoints are working correctly!'); } catch (error) { console.error('โŒ Test failed:', error.response?.data?.message || error.message); if (error.code === 'ECONNREFUSED') { console.error('\n๐Ÿ’ก Make sure the server is running:'); console.error(' cd api && npm start'); } } } testEndpoints();