nose-pluto/bin/share.ts
Chris Wanstrath 3ec5b8d1e5 wip
2025-10-10 14:57:48 -07:00

26 lines
744 B
TypeScript

// Share a webapp with the public internet.
import { apps } from "@/webapp/server"
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}: <a href="${url}">${url}</a>`
}).join("\n")
}
return { html: out }
}
if (!apps().includes(app)) {
return { error: `${app} not found` }
}
const url = sneakerUrl(await connectSneaker(app))
return { html: `<a href="${url}">${url}</a>` }
}