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

chadtmiller.com/pds.js

An atproto PDS in JavaScript, for Cloudflare Workers and Node

0
0
main
23 lines · 836 B Raw History
// Wrap the built document in an ES module.
//
// The PDS has no filesystem on Workers and no build step of its own, so the
// application reaches it as an import rather than as a static directory: one
// module exporting one string, which a platform package hands to the server.

import { readFileSync, writeFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';

const dist = new URL('../dist/', import.meta.url);
const html = readFileSync(new URL('index.html', dist), 'utf8');

writeFileSync(
  new URL('assets.js', dist),
  `// Generated by scripts/emit-assets.js. Do not edit.\n` +
    `export const accountApp = ${JSON.stringify(html)};\n` +
    `export default accountApp;\n`,
);

const kb = (html.length / 1024).toFixed(0);
console.log(
  `account-ui: ${kb} kB -> ${fileURLToPath(new URL('assets.js', dist))}`,
);