I was looking into importing configurations in the proofofbrain.blog software. If I have a configuration set such as default night/day mode, is it determined at "compile time" (when I build the software and get it ready for use), or at start up time (when I actually start the server), or during runtime (it automatically reloads parameters on the go). There are two short ways to load configuration files: 1. JSON file 2. A Type Script module file A JSON file imports in each file that uses the constant like this: ``` import defaults from "../constants/site.json"; ``` The JSON needs another file to describe the types of and which constants are set therein.  Photo by [Justin Campbell](https://unsplash.com/@justinhikestn?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/jason?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) The typescript approach is just export constants in a typescript file and then import them like this: ``` import { LIQUID_TOKEN_UPPERCASE } from "../client_config"; ``` It turns out both the constants in the JSON and Typescript includes happen at "compile time." So there is no advantage in one or the other in this sense. If you use a configuration file, then you should be able to compile the typescript into finished software and then modify the configuration after the fact. Or move the compiled software from a place that is configured for testing to another (with distinct configurations). This is what I was hoping for with the JSON file. Ideally, it should reload the JSON when there is a change. It turns out this approach doesn't provide this as I hoped. It turns out you can have type safety in the JSON file, but you already get that by leaving it in a typescript file. It seems like these should be variables that can be overridden with parameters set in a JSON file. However, if the typescript exports various constants, you need to write lines of code for each constant. The typescript needs to export a single export or the loading code will be ad-hoc. Finally the front end will be unable to use something stored in a JSON file in the file system so anyway it seems we are stuck with compile time constants unless it is loaded from HTTPS.
author | leprechaun |
---|---|
permlink | including-json-vs-ts |
category | hive-169321 |
json_metadata | {"links":["https://unsplash.com/@justinhikestn?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText","https://unsplash.com/s/photos/jason?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText"],"image":["https://images.ecency.com/DQmexZP33RrYPjrRQnoNuuEdQsmKuYT13bop8CTRBmghc5o/justin_campbell_zayydj9hjme_unsplash.jpg"],"tags":["hive-169321","programming","typescript","json","ts","bluebrain"],"app":"localhost/3.0.18","format":"markdown+html"} |
created | 2021-08-25 12:33:30 |
last_update | 2021-08-25 12:55:33 |
depth | 0 |
children | 2 |
last_payout | 2021-09-01 12:33:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.168 HBD |
curator_payout_value | 0.164 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 2,454 |
author_reputation | 43,025,797,524,251 |
root_title | "Including JSON vs. TS" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 105,783,828 |
net_rshares | 405,631,464,788 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
drifter1 | 0 | 39,682,761,486 | 100% | ||
dwinblood | 0 | 16,270,041,303 | 20% | ||
darkflame | 0 | 112,149,898,530 | 100% | ||
richardcrill | 0 | 130,502,151,539 | 50% | ||
joeyarnoldvn | 0 | 539,793,696 | 1.66% | ||
tipy | 0 | 2,464,158,438 | 100% | ||
steemexperience | 0 | 72,463,947,318 | 50% | ||
hranhuk | 0 | 6,865,220,153 | 25% | ||
reverendrum | 0 | 1,285,485,628 | 100% | ||
oh-high-mark | 0 | 3,506,184,075 | 66.6% | ||
gangstalking | 0 | 1,155,684,827 | 1.5% | ||
thranax | 0 | 5,337,437,446 | 20% | ||
esther-emmanuel | 0 | 6,890,288,804 | 100% | ||
mundo.curioso | 0 | 544,810,706 | 100% | ||
readthisplease | 0 | 3,633,992,224 | 100% | ||
biggestloser | 0 | 2,339,608,615 | 100% | ||
ppopescu | 0 | 0 | 100% |
This is really interesting to me. I want to learn how to script on <a href="https://developers.hive.io/">Hive</a>, so I am searching for and reviewing a lot of materials lately. Trying to go back to the basics (<a href="https://www.w3schools.com/whatis/whatis_json.asp">json</a>) I see how you were trying to get the two typescript and json to work together but did it not give you the desired result. Finding new ways to work around problems leads to creative solutions or at least attempts. I have built so many websites and they have all been thrown away, but now I use Hive and want to build web3 pages with tools and games. Your proofofbrain.blog front end is great! I appreciate how complex it is to modify and deploy. It's helpful to users like me to see the overall token breakdown, and how the top left icon takes you to <a href="https://www.proofofbrain.blog/created/hive-150329">POB</a> <- I love it! The landing page with the <a href="https://www.proofofbrain.blog/hive-150329/@leprechaun/the-absolute-beginner-s-guide-to-proof-of-brain">beginners guide</a> is a really good idea for new readers.
author | darkflame |
---|---|
permlink | re-leprechaun-qymcap |
category | hive-169321 |
json_metadata | {"tags":["hive-169321"],"app":"peakd/2021.07.5"} |
created | 2021-08-29 20:44:48 |
last_update | 2021-08-29 20:44:48 |
depth | 1 |
children | 0 |
last_payout | 2021-09-05 20:44:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,108 |
author_reputation | 91,308,866,075,809 |
root_title | "Including JSON vs. TS" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 105,878,978 |
net_rshares | 76,347,912 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
leprechaun | 0 | 76,347,912 | 3.2% |
Electronic-terrorism, voice to skull and neuro monitoring on Hive and Steem. You can ignore this, but your going to wish you didnt soon. This is happening whether you believe it or not. https://ecency.com/fyrstikken/@fairandbalanced/i-am-the-only-motherfucker-on-the-internet-pointing-to-a-direct-source-for-voice-to-skull-electronic-terrorism
author | gangstalking |
---|---|
permlink | re-leprechaun-including-json-vs-ts-20210825t123336815z |
category | hive-169321 |
json_metadata | {"app":"hive-bot/0.6.3"} |
created | 2021-08-25 12:33:39 |
last_update | 2021-08-25 12:33:39 |
depth | 1 |
children | 0 |
last_payout | 2021-09-01 12:33:39 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 343 |
author_reputation | -67,597,107,868,724 |
root_title | "Including JSON vs. TS" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 105,783,832 |
net_rshares | -26,399,759,967 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
spaminator | 0 | -4,978,501,123 | -0.25% | ||
mmmmkkkk311 | 0 | -21,421,258,844 | -0.25% |