26 lines
749 B
TypeScript
26 lines
749 B
TypeScript
// Share a webapp with the public internet.
|
|
|
|
import { apps } from "app/src/webapp"
|
|
import { connectSneaker, sneakers, sneakerUrl } from "app/src/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>` }
|
|
} |