@atproto/ozone
Version:
Backend service for moderating the Bluesky network.
100 lines • 3.58 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.envToCfg = void 0;
const node_assert_1 = __importDefault(require("node:assert"));
const common_1 = require("@atproto/common");
// off-config but still from env:
// logging: LOG_LEVEL, LOG_SYSTEMS, LOG_ENABLED, LOG_DESTINATION
const envToCfg = (env) => {
const port = env.port ?? 3000;
(0, node_assert_1.default)(env.publicUrl, 'publicUrl is required');
(0, node_assert_1.default)(env.serverDid, 'serverDid is required');
const serviceCfg = {
port,
publicUrl: env.publicUrl,
did: env.serverDid,
version: env.version,
devMode: env.devMode,
};
(0, node_assert_1.default)(env.dbPostgresUrl, 'dbPostgresUrl is required');
const dbCfg = {
postgresUrl: env.dbPostgresUrl,
postgresSchema: env.dbPostgresSchema,
poolSize: env.dbPoolSize,
poolMaxUses: env.dbPoolMaxUses,
poolIdleTimeoutMs: env.dbPoolIdleTimeoutMs,
materializedViewRefreshIntervalMs: env.dbMaterializedViewRefreshIntervalMs,
teamProfileRefreshIntervalMs: env.dbTeamProfileRefreshIntervalMs,
};
(0, node_assert_1.default)(env.appviewUrl, 'appviewUrl is required');
(0, node_assert_1.default)(env.appviewDid, 'appviewDid is required');
const appviewCfg = {
url: env.appviewUrl,
did: env.appviewDid,
pushEvents: !!env.appviewPushEvents,
};
let pdsCfg = null;
if (env.pdsUrl || env.pdsDid) {
(0, node_assert_1.default)(env.pdsUrl, 'pdsUrl is required');
(0, node_assert_1.default)(env.pdsDid, 'pdsDid is required');
pdsCfg = {
url: env.pdsUrl,
did: env.pdsDid,
};
}
let chatCfg = null;
if (env.chatUrl || env.chatDid) {
(0, node_assert_1.default)(env.chatUrl, 'chatUrl is required when chatDid is provided');
(0, node_assert_1.default)(env.chatDid, 'chatDid is required when chatUrl is provided');
chatCfg = {
url: env.chatUrl,
did: env.chatDid,
};
}
const cdnCfg = {
paths: env.cdnPaths,
};
(0, node_assert_1.default)(env.didPlcUrl, 'didPlcUrl is required');
const identityCfg = {
plcUrl: env.didPlcUrl,
cacheMaxTTL: env.didCacheMaxTTL ?? common_1.DAY,
cacheStaleTTL: env.didCacheStaleTTL ?? common_1.HOUR,
};
const blobDivertServiceCfg = env.blobDivertUrl && env.blobDivertAdminPassword
? {
url: env.blobDivertUrl,
adminPassword: env.blobDivertAdminPassword,
}
: null;
const accessCfg = {
admins: env.adminDids,
moderators: env.moderatorDids,
triage: env.triageDids,
};
const verifierCfg = env.verifierUrl && env.verifierDid && env.verifierPassword
? {
url: env.verifierUrl,
did: env.verifierDid,
password: env.verifierPassword,
issuersToIndex: env.verifierIssuersToIndex,
}
: null;
return {
service: serviceCfg,
db: dbCfg,
appview: appviewCfg,
pds: pdsCfg,
chat: chatCfg,
cdn: cdnCfg,
identity: identityCfg,
blobDivert: blobDivertServiceCfg,
access: accessCfg,
verifier: verifierCfg,
jetstreamUrl: env.jetstreamUrl,
};
};
exports.envToCfg = envToCfg;
//# sourceMappingURL=config.js.map