59 lines
2.1 KiB
JavaScript

require('dotenv').config();
const config = {
bus: {
url: process.env.BUS_URL,
mpiUrl: process.env.MPI_URL || process.env.BUS_URL,
documentRegistryUrl: process.env.DOCUMENT_REGISTRY_URL || process.env.BUS_URL,
jwtSecret: process.env.BUS_JWT_SECRET,
issuer: process.env.BUS_ISSUER,
mpiScope: process.env.MPI_SCOPE,
documentRegistryScope: process.env.DOCUMENT_REGISTRY_SCOPE,
},
fhir: {
url: process.env.FHIR_URL,
},
logging: {
enabled: true,
level: 'debug',
depthLimit: 5,
edgeLimit: 100,
msgPrefix: undefined,
crlf: false,
messageKey: 'msg',
errorKey: 'err',
nestedKey: null,
},
vhl: {
// Path to an EC P-256 private key in PEM format for signing CWTs.
// If omitted, an ephemeral key is generated at startup (lost on restart).
privateKeyFile: process.env.VHL_PRIVATE_KEY_FILE,
// URI identifying this gateway as the CWT issuer (iss claim).
// Defaults to BUS_ISSUER so no extra variable is needed in most deployments.
issuer: process.env.VHL_ISSUER || process.env.BUS_ISSUER,
// Public base URL of this gateway, used to build manifest and document URLs.
// Required when the VHL endpoints are used.
baseUrl: process.env.VHL_BASE_URL,
// VHL token and document TTL in seconds (default: 7 days).
ttl: parseInt(process.env.VHL_TOKEN_TTL || '604800', 10),
},
baseURL: process.env.NODO_BASE_URL || 'http://localhost',
debug: process.env.BUS_DEBUG === 'true',
};
const required = [
['BUS_URL', config.bus.url],
['BUS_JWT_SECRET', config.bus.jwtSecret],
['BUS_ISSUER', config.bus.issuer],
['MPI_SCOPE', config.bus.mpiScope],
['DOCUMENT_REGISTRY_SCOPE', config.bus.documentRegistryScope],
['FHIR_URL', config.fhir.url],
];
const missing = required.filter(([, val]) => !val).map(([key]) => key);
if (missing.length > 0) {
throw new Error(`Missing required environment variables: ${missing.join(', ')}`);
}
module.exports = config;