generated from fahricansecer/boilerplate-be
This commit is contained in:
56
test-api.js
Normal file
56
test-api.js
Normal file
@@ -0,0 +1,56 @@
|
||||
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();
|
||||
Reference in New Issue
Block a user