improve dockerization
This commit is contained in:
34
test-endpoints.js
Normal file
34
test-endpoints.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const axios = require('axios');
|
||||
|
||||
const BASE = 'http://localhost:3630/api/watchlist';
|
||||
|
||||
async function test() {
|
||||
try {
|
||||
console.log('1. Getting watchlist...');
|
||||
const res1 = await axios.get(BASE);
|
||||
console.log(` Success. Items: ${res1.data.length}`);
|
||||
|
||||
console.log('2. Adding "Inception"...');
|
||||
const res2 = await axios.post(BASE, { title: 'Inception', type: 'movie' });
|
||||
console.log(` Success. ID: ${res2.data.id}`);
|
||||
const newId = res2.data.id;
|
||||
|
||||
console.log('3. Toggling watched status...');
|
||||
const res3 = await axios.put(`${BASE}/${newId}/toggle`);
|
||||
console.log(` Success. Watched: ${res3.data.watched}`);
|
||||
|
||||
console.log('4. Deleting item...');
|
||||
const res4 = await axios.delete(`${BASE}/${newId}`);
|
||||
console.log(` Success.`);
|
||||
|
||||
console.log('All tests passed!');
|
||||
} catch (err) {
|
||||
console.error('Test failed:', err.message);
|
||||
if (err.response) {
|
||||
console.error('Data:', err.response.data);
|
||||
console.error('Status:', err.response.status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test();
|
||||
Reference in New Issue
Block a user