// Share a webapp with the public internet.
import { apps } from "@/webapp/utils"
import { connectSneaker, sneakers, sneakerUrl } from "@/sneaker"
export default async function (app: string) {
if (!app) {
let out = `usage: share <app> [subdomain]`
const apps = sneakers()
if (apps.length) {
out += "\n\nUse `unshare` to stop sharing an app."
out += "\n\nsharing\n" + apps.map(app => {
const url = sneakerUrl(app)
return `${app}: ${url}`
}).join("\n")
}
return { html: out }
}
if (!apps().includes(app)) {
return { error: `${app} not found` }
}
const url = sneakerUrl(await connectSneaker(app))
return { html: `${url}` }
}