-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Ly Dinh Minh Man <[email protected]> Co-authored-by: droak <[email protected]>
- Loading branch information
1 parent
2732d31
commit fe9d267
Showing
7 changed files
with
81 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.env | ||
|
||
dist/ | ||
docs/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ADDRESSES=/ip4/0.0.0.0/tcp/50000/ws,/ip4/0.0.0.0/tcp/50001 | ||
BOOTSTRAP=true | ||
BOOTSTRAP_PEERS=/dns4/relay.droak.sh/tcp/443/wss/p2p/Qma3GsJmB47xYuyahPZPSadh1avvxfyYQwk8R3UnFrQ6aP | ||
PRIVATE_KEY_SEED=example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import fs from "node:fs"; | ||
import * as dotenv from "dotenv"; | ||
import type { TopologyNodeConfig } from "./index.js"; | ||
|
||
export function loadConfig( | ||
configPath?: string | undefined, | ||
): TopologyNodeConfig | undefined { | ||
let config: TopologyNodeConfig | undefined; | ||
|
||
if (configPath) { | ||
config = JSON.parse(fs.readFileSync(configPath, "utf8")); | ||
return config; | ||
} | ||
|
||
const result = dotenv.config(); | ||
if (!result.error) { | ||
config = {}; | ||
config.network_config = { | ||
addresses: process.env.ADDRESSES | ||
? process.env.ADDRESSES.split(",") | ||
: undefined, | ||
bootstrap: process.env.BOOTSTRAP | ||
? process.env.BOOTSTRAP === "true" | ||
: undefined, | ||
bootstrap_peers: process.env.BOOTSTRAP_PEERS | ||
? process.env.BOOTSTRAP_PEERS.split(",") | ||
: undefined, | ||
browser_metrics: process.env.BROWSER_METRICS | ||
? process.env.BROWSER_METRICS === "true" | ||
: undefined, | ||
private_key_seed: process.env.PRIVATE_KEY_SEED | ||
? process.env.PRIVATE_KEY_SEED | ||
: undefined, | ||
}; | ||
return config; | ||
} | ||
|
||
return config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const VERSION = "0.2.1-3"; | ||
export const VERSION = "0.2.1-4"; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.