add pds service source code

main
Charlotte Som 2024-11-19 05:25:01 +00:00
parent 3e4a52e6dd
commit f715b42a47
6 changed files with 5961 additions and 0 deletions

2
pds/.gitignore vendored
View File

@ -1 +1,3 @@
/data /data
/node_modules
/.env

23
pds/flake.lock Normal file
View File

@ -0,0 +1,23 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 0,
"narHash": "sha256-df3dJApLPhd11AlueuoN0Q4fHo/hagP75LlM5K1sz9g=",
"path": "/nix/store/ly4s3hw35dd1c2vsd694y2715pc1d2c1-source",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

13
pds/flake.nix Normal file
View File

@ -0,0 +1,13 @@
{
description = "pds";
outputs = { self, nixpkgs }: let
pkgs = import nixpkgs { system = "x86_64-linux"; };
in {
devShells."x86_64-linux".default = pkgs.mkShell {
buildInputs = [
pkgs.nodejs_22
];
};
};
}

29
pds/index.mjs Normal file
View File

@ -0,0 +1,29 @@
import "dotenv/config";
import { envStr } from "@atproto/common";
import { PDS, envToCfg, envToSecrets, readEnv } from "@atproto/pds";
import pkg from "@atproto/pds/package.json" with { type: "json" };
import process from "node:process";
const main = async () => {
const env = readEnv();
env.version ||= pkg.version;
const cfg = envToCfg(env);
const secrets = envToSecrets(env);
const pds = await PDS.create(cfg, secrets);
// allow listening on non-0.0.0.0 addresses
const host = envStr("BIND_HOST") ?? "127.0.0.1";
const oListen = pds.app.listen;
pds.app.listen = (port, ...args) => {
return oListen(port, host, ...args);
}
await pds.start();
process.on("SIGTERM", async () => {
await pds.destroy();
});
};
main();

5878
pds/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

16
pds/package.json Normal file
View File

@ -0,0 +1,16 @@
{
"name": "pds",
"private": true,
"version": "0.0.0",
"description": "Service entrypoint for atproto personal data server",
"main": "index.js",
"license": "MIT",
"dependencies": {
"@atproto/pds": "0.4.71",
"dotenv": "^16.4.5",
"express": "^4.21.1"
},
"devDependencies": {
"@types/express": "^5.0.0"
}
}