#!/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();