P
P
Polina Titova2021-05-05 12:40:47
JavaScript
Polina Titova, 2021-05-05 12:40:47

How to know if data is being transferred or not?

To connect to the database, there is a preliminary inspection for the presence of all the necessary parameters. The condition is written, if something is missing, then
an error will be displayed:

const {DB_NAME, DB_USER, DB_PASSWORD, DB_HOST, DB_PORT} = process.env;

const somethingIsNotDefined = [DB_NAME, DB_USER, DB_PASSWORD, DB_HOST, DB_PORT].some((it) => it === undefined);

if (somethingIsNotDefined) {
  throw new Error(`One or more environmental variables are not defined`);
}

In the .env file, we pass variables with values ​​that are used for this connection.
DB_NAME=buy_and_sell
DB_USER=user
DB_PASSWORD=password
DB_HOST=localhost
DB_PORT=5432

When you run the program in the console, an error is displayed, which we obviously identified above. The condition is triggered, but why? There is an assumption that information is being leaked, while how can you check where it goes or whether it comes at all? There are also a couple of commands for displaying status or similar information in a log file. This is the message that was displayed there after the launch:
{"level":50,"time":1620121263715,"pid":12590,"hostname":"Poly-Extensa-5230","name":"base-logger","msg":"An error occured: password authentication failed for user \"andrew\""}

All the same, the parameters are passed in the file, then where did this particular user come from ? What is the reason, and how can it be corrected?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Polina Titova, 2021-05-07
@poly-titova

Installed the dotenv library, used it as it should and it worked

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question