decentralised sync engine

feat: owner did env var

serenity 23aa3fe0 2138e5cc

Changed files
+23
src
lib
+5
.example.env
···
# defaults to did:web:localhost
SERVICE_DID="did:web:localhost"
+
# required.
+
# owner did
+
# used to verify ownership of this shard and its related channels
+
OWNER_DID=
+
# to tell if you're in dev or prod. defaults to dev.
# if running in prod, set to 'production'
NODE_ENV="development"
+18
src/lib/env.ts
···
import { didSchema } from "@/lib/types/atproto";
import "dotenv/config";
+
import { z } from "zod";
const nodeEnv = process.env.NODE_ENV;
export const NODE_ENV = nodeEnv ?? "development";
···
);
}
export const SERVICE_DID = serviceDidParsed ?? "did:web:localhost";
+
+
const ownerDid = process.env.OWNER_DID;
+
const {
+
success: ownerDidParseSuccess,
+
error: ownerDidParseError,
+
data: ownerDidParsed,
+
} = didSchema.safeParse(ownerDid);
+
if (!ownerDidParseSuccess) {
+
console.error(
+
"Could not parse OWNER_DID environment variable. Ensure that it is set and that it is a valid ATProto DID.",
+
);
+
console.error(
+
"See the example environment variables file for more information. `.example.env` in the project root.",
+
);
+
throw new Error(z.prettifyError(ownerDidParseError));
+
}
+
export const OWNER_DID = ownerDidParsed;