Skip to content

Commit

Permalink
fix: cwd-agnostic path to the genesis files
Browse files Browse the repository at this point in the history
  • Loading branch information
slowbackspace committed Nov 13, 2024
1 parent 87c1015 commit 8bad187
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import config from 'config';
import { ByronEraParameters, CARDANO_NETWORKS, Network } from './types/common.js';
import { readFileSync } from 'node:fs';
import * as ResponseTypes from './types/responses/ledger.js';
import { fileURLToPath } from 'url';
import path from 'path';

// Get the directory name of the current module
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const MITHRIL_ENDPOINT_ALLOWLIST_DEFAULT = [
'', // root endpoint, same as "/", but some env are trimming trailing slash so request to /mithril/ could be received as /mithril
Expand Down Expand Up @@ -110,7 +116,7 @@ export const loadConfig = () => {
const genesisDataFolder =
process.env.BLOCKFROST_CONFIG_GENESIS_DATA_FOLDER ?? config.has('genesisDataFolder')
? config.get<string>('genesisDataFolder')
: `./genesis/${network}`;
: path.resolve(__dirname, '../', 'genesis', network);

const genesis = JSON.parse(
readFileSync(genesisDataFolder + '/genesis.json', 'utf8'),
Expand Down

0 comments on commit 8bad187

Please sign in to comment.