async function main () {
  // Initialize database
  await db.init()

  try {
    // Load configuration from file
    const configPath = path.join(__dirname, 'nostr-link-extract.config.json')
    logger.info(`Loading configuration from ${configPath}`)
    config = loadConfig(configPath)

    logger.info(`Starting Nostr link extraction (time interval: ${config.timeIntervalHours} hours)`)

    // Convert any npub format keys to hex
    const hexUserPubkeys = config.userPubkeys.map(normalizeToHexPubkey)
    const hexIgnorePubkeys = config.ignorePubkeys.map(normalizeToHexPubkey)

    // Log the conversion for clarity (helpful for debugging)
    if (config.userPubkeys.some(key => key.startsWith('npub1'))) {
      logger.debug('Converted user npubs to hex format for Nostr protocol')
    }
    if (config.ignorePubkeys.some(key => key.startsWith('npub1'))) {
      logger.debug('Converted ignore list npubs to hex format for Nostr protocol')
    }

    const notesWithLinks = await getNotesWithLinks(
      hexUserPubkeys,
      config.timeIntervalHours,
      config.relayUrls,
      hexIgnorePubkeys
    )

    if (notesWithLinks.length > 0) {
      const formattedOutput = formatNoteOutput(notesWithLinks)
      console.log(formattedOutput)
      logger.result(`Total notes with links: ${notesWithLinks.length}`)
    } else {
      logger.info('No notes with links found in the specified time interval.')
    }
  } catch (error) {
    logger.error(`${error}`)
  } finally {
    // Close database connection
    await db.close()
  }
}
Main function to execute the script