~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/pds.js

An atproto PDS in JavaScript, for Cloudflare Workers and Node

0
0
main
50 lines · 2.1 KB Raw History
// The port shapes the sites package builds and its account routes read.

/**
 * Serves static sites from the repo on hostnames other than the server's.
 * A null return means the hostname is not a site hostname and the request
 * falls through to normal dispatch.
 *
 * @typedef {(request: Request, url: URL) => Promise<Response|null>} SiteHandlerPort
 */

/**
 * Read-only view of this account's deployed sites, for the account page.
 *
 * @typedef {Object} SiteBrowserPort
 * @property {string} domain - apex domain sites serve under
 * @property {string} apexName - site name bound to the apex
 * @property {() => Promise<SiteRow[]>} listSites
 * @property {(name: string) => Promise<SiteFileRow[]|null>} listFiles - the named site's manifest entries, or null when no such site exists
 */

/**
 * Server-side app installs, driven from the account page.
 *
 * @typedef {Object} SiteInstallerPort
 * @property {(uri: string) => Promise<Record<string, unknown>>} preview - the install sheet's view of a manifest
 * @property {(uri: string, options?: {site?: string, config?: Record<string, unknown>}) => Promise<{site: string, name: string}>} install
 * @property {(uri: string, pinnedCid: string) => Promise<{currentCid: string, changed: boolean}>} checkUpdate
 * @property {(installUri: string, newName: string) => Promise<{site: string}>} rename - move an install's site to a new subdomain label
 */

/**
 * @typedef {Object} SiteFileRow
 * @property {string} path
 * @property {number} size - bytes, from the blob ref
 * @property {string} contentType - manifest override, else the stored blob mime
 * @property {string} cid - the file's blob CID
 */

/**
 * @typedef {Object} SiteRow
 * @property {string} name - site name (the deploy record's rkey)
 * @property {string} url - the site's canonical https URL
 * @property {number} fileCount
 * @property {number} totalSize - bytes, summed from blob-ref sizes
 * @property {string|null} deployedAt - the deploy record's createdAt
 * @property {string} cid - the deploy record's CID
 * @property {boolean} servable - whether the record key is a valid DNS label (an invalid one deploys fine but no hostname reaches it)
 */

export {};