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

chadtmiller.com/pds.js

An atproto PDS in JavaScript, for Cloudflare Workers and Node

0
0
main
55 lines · 1.3 KB Raw History

Deploy: Deno

The Deno server stores the repo in node:sqlite and the blobs on local disk. It needs Deno 2.2 or later for node:sqlite.

Run it

cd examples/deno
deno run --allow-net --allow-read --allow-write --allow-env main.ts

The server needs four permissions:

PermissionReason
--allow-netThe HTTP server, and outbound requests to the PLC, relay, and AppView
--allow-readThe database and the blob files
--allow-writeThe database and the blob files
--allow-envThe configuration

examples/deno/main.ts closes the database on SIGINT and SIGTERM.

As a library

import { createServer } from '@pdsjs/deno'

const { listen } = await createServer({
  dbPath: './pds.db',
  blobsDir: './blobs',
  jwtSecret: Deno.env.get('JWT_SECRET'),
  hostname: 'your-hostname.com',
  port: 3000,
})

await listen()

Finish the setup

Terminate TLS with a reverse proxy such as nginx or Caddy. Set HOSTNAME to the public domain.

Then register the DID with the PLC directory. Run this once, after the PDS answers at its public URL:

npm run setup -- --pds https://your-hostname.com

Configuration

examples/deno/README.md lists the variables the example reads. The names match the Node server. See configuration.