52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Test Portfolio API Response
|
|
*/
|
|
|
|
const { query } = require("./config/database");
|
|
|
|
async function testPortfolioAPI() {
|
|
console.log("🧪 Testing Portfolio API Data...\n");
|
|
|
|
try {
|
|
// Simulate what the API endpoint does
|
|
const result = await query(
|
|
"SELECT id, title, description, imageurl, category, isactive, createdat FROM portfolioprojects ORDER BY createdat DESC"
|
|
);
|
|
|
|
console.log("📊 API Response Data:\n");
|
|
result.rows.forEach((p, index) => {
|
|
const status = p.isactive ? "✓ Active" : "✗ Inactive";
|
|
const statusColor = p.isactive ? "\x1b[32m" : "\x1b[31m";
|
|
const reset = "\x1b[0m";
|
|
|
|
console.log(
|
|
`${index + 1}. ${statusColor}${status}${reset} | ID: ${p.id} | ${
|
|
p.title
|
|
}`
|
|
);
|
|
console.log(
|
|
` isactive value: ${p.isactive} (type: ${typeof p.isactive})`
|
|
);
|
|
console.log(` category: ${p.category || "N/A"}`);
|
|
console.log("");
|
|
});
|
|
|
|
const activeCount = result.rows.filter((p) => p.isactive).length;
|
|
const inactiveCount = result.rows.length - activeCount;
|
|
|
|
console.log(`\n📈 Summary:`);
|
|
console.log(` Total: ${result.rows.length} projects`);
|
|
console.log(` ✓ Active: ${activeCount}`);
|
|
console.log(` ✗ Inactive: ${inactiveCount}\n`);
|
|
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error("❌ Error:", error.message);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
testPortfolioAPI();
|