// Quick test to verify auth middleware loading
const fs = require("fs");
const path = require("path");

let output = "";

function log(msg) {
  output += msg + "\n";
  console.log(msg);
}

try {
  log("Testing auth middleware...");

  const auth = require("./middleware/auth");
  log("Auth exports: " + Object.keys(auth).join(", "));
  log("authenticate type: " + typeof auth.authenticate);

  const lists = require("./routes/lists");
  log("Lists routes loaded: " + (lists ? "YES" : "NO"));

  log("");
  log("✅ All modules load correctly!");
  log("");
  log("If you are still getting 403, the backend service needs restart:");
  log("  sudo systemctl restart church-music-backend.service");
} catch (err) {
  log("❌ ERROR: " + err.message);
  log(err.stack);
}

// Write to file
fs.writeFileSync(path.join(__dirname, "test-auth-result.txt"), output);
