One event, everywhere
A single hook defines web:search. The tool and the route own no
logic — they just fire $('web:search', args). Run it live on the right.
const { $ } = require('logos')
// The hook *is* the event. Real logic lives here, once.
const onSearch = async ({ term }) => {
/**
* @register_hook web:search
*/
const res = await fetch(`https://api.duckduckgo.com/?q=${term}`)
return (await res.json()).results
}
module.exports = { onSearch }