Files
SkyArtShop/backend/test-portfolio-api.js
Local Server 017c6376fc updateweb
2025-12-24 00:13:23 -06:00

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();