#!/usr/bin/env nu

# Post-server-create hook for DigitalOcean
# Sends notifications after server creation

def main [context: string] {
    let ctx = ($context | from json)

    print $"📡 Sending notification for DigitalOcean server creation..."

    # Extract server info from context
    let servers = ($ctx | get -o servers | default [])

    $servers | each {|server|
        print $"✅ Server created: ($server.hostname) in ($server.region)"

        # Here you could send to Slack, Discord, email, etc.
        # Example: webhook notification
        # http post $webhook_url { server: $server.hostname, status: "created" }
    }

    # Output notification results
    {
        provider: "digitalocean"
        notification: "sent"
        servers_notified: ($servers | length)
    } | to json
}