B
B
bihim2017-06-19 17:38:07
bash
bihim, 2017-06-19 17:38:07

How to use sensitive data in Node using Linux?

Hello.
How to use (pass to the application) various important data, keys, environment variables, etc. through the console? At the moment I am using the node.js dotenv library, but I know that you can generally do everything without a library, using bash.
I can't find any clear instructions on how to do this. I found a tutorial, it starts with the words open open .bash_profileand it gives me an error, I don’t have such a file.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Cheremisin, 2017-06-19
@leahch

It is possible through json and curl. Prepare a json file and fire it with curl.

S
Saboteur, 2017-06-20
@saboteur_kiev

Variables are easy to pass - they must be marked for export.
export variable=value
Thus, this variable will be copied to all child processes (for example, to your node.js)
Changing the configuration file itself does not affect the current session - after the change, you either need to restart/reboot, or simply re-execute the file, for example:
source . bash_profile
Which file to store in depends on how you start processes.
.bashrc - if you log in via bash to the console
.profile - if you open a terminal via gui
.bash_profile - in both cases
But you can just add any variable to the file, relogin and check if it exists via
echo $variable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question