Files
ContentGen_BE/test-api.js
Harun CAN 9486f86cca
Some checks failed
Backend Deploy 🚀 / build-and-deploy (push) Has been cancelled
main
2026-04-05 20:37:15 +03:00

57 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
async function test() {
try {
// 1. Admin login
const loginRes = await fetch('http://localhost:3000/api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: 'admin@contentgen.ai', password: 'Admin123!' })
});
const loginData = await loginRes.json();
const token = loginData.data.accessToken;
console.log("Logged in!");
// 2. Create project from standard prompt
console.log("\n--- Creating standard project...");
const projRes = await fetch('http://localhost:3000/api/projects', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
title: "Test Project",
prompt: "Uzay hakkında bir belgesel",
language: "tr",
videoStyle: "CINEMATIC",
aspectRatio: "PORTRAIT_9_16"
})
});
const projData = await projRes.json();
console.log("Standard project status:", projRes.status);
console.log("Standard project result:", JSON.stringify(projData, null, 2));
// 3. Create project from tweet
console.log("\n--- Creating tweet project...");
const tweetRes = await fetch('http://localhost:3000/api/projects/from-tweet', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
tweetUrl: "https://x.com/elonmusk/status/1893456789012345678",
language: "tr",
videoStyle: "CINEMATIC",
aspectRatio: "PORTRAIT_9_16"
})
});
const tweetData = await tweetRes.json();
console.log("Tweet project status:", tweetRes.status);
console.log("Tweet project result:", JSON.stringify(tweetData, null, 2));
} catch (err) {
console.error("Error:", err);
}
}
test();