const fs = require('fs');
const content = fs.readFileSync('./dist/server.cjs', 'utf8');

function printBlock(searchStr) {
  let idx = content.indexOf(searchStr);
  if (idx !== -1) {
    console.log(`=== FOUND "${searchStr}" ===`);
    // Find enclosing block or next 1000 characters
    let endIdx = content.indexOf('app.post(', idx + 10);
    if (endIdx === -1) endIdx = idx + 2000;
    console.log(content.substring(idx, endIdx));
  } else {
    console.log(`=== NOT FOUND "${searchStr}" ===`);
  }
}

printBlock('app.post("/api/mikrotik/update-hotspot-profile"');
printBlock('app.post("/api/mikrotik/add-hotspot-profile"');
