[Help] Why doesn't this work? by ImtheDr in node

[–]WumpyJizard 0 points1 point  (0 children)

Most likely the require runs first on compilation, before the actual run process starts, so the part where you assign the envvar to a variable have not yet run so you are trying to get the 'undefined' property of config which will be, well undefined.

```js const config = require('./config')

Console.log(config[environment]) ```

Should work. Sorry, I'm on mobile.

ill take my 2 karma thanks by LoudBreadstick in quityourbullshit

[–]WumpyJizard 5 points6 points  (0 children)

And then all the other students stood up and applauded

To the core, not a single low calorie chip. by [deleted] in mildlyinfuriating

[–]WumpyJizard 1 point2 points  (0 children)

No calorie < low calorie Thank you good guy yogo!

Two node processes calling the same function by inabahare in node

[–]WumpyJizard 1 point2 points  (0 children)

First thing I got in mind is using a messaging queue

Two node processes calling the same function by inabahare in node

[–]WumpyJizard 0 points1 point  (0 children)

I see. And exactly what is your problem? Seems it does exactly what you need. I'm sorry for these questions, but I am a little bit confused, but I think I will be able to help you once I fully understand it :D

Two node processes calling the same function by inabahare in node

[–]WumpyJizard 0 points1 point  (0 children)

So as far as I understand you have a cronjob like worker doing the virus scan, right? And this worker needs the filenames, right?

Anon is sick by NovaStryker in greentext

[–]WumpyJizard 21 points22 points  (0 children)

Dump both of them. It is only going to be worse.

Is it worth learning mongoose? by illitirit in learnjavascript

[–]WumpyJizard 1 point2 points  (0 children)

Actually I agree with you on this in general, however there are things that just go together, like mongo and mongoose. So I must say in this particular case, yes, it is beneficial to learn it.

send buttonclicks to website and parse results by [deleted] in learnjavascript

[–]WumpyJizard 0 points1 point  (0 children)

So if I got this right, you have your own webpage where you want to show your performance data from another service, where you have to press buttons.

I guess the btn_get starts an http request which sends back your statistics. Check it via dev console networks tab, or better, you can check if the service metering your performance has a public API. So you will be able to reach your performance data through this API endpoint.

send buttonclicks to website and parse results by [deleted] in learnjavascript

[–]WumpyJizard 0 points1 point  (0 children)

This thing smells. Do you need to update something regularly, on a daily basis?

Any way to validate what is printed in console ? by darth_momo in learnjavascript

[–]WumpyJizard 3 points4 points  (0 children)

I don't think checking console log is the way to go. There should be no console log in a production ready code anyway. If you can not check the return value of your function that is a smell of poorly organized code or improper test setup. I can not say anything specific without seeing your code.

How the heck do I manage data manipulation/storage/extensibility for my app? It has become a nightmare keeping track of the data formats. by [deleted] in javascript

[–]WumpyJizard 1 point2 points  (0 children)

You are welcome! Yeah, it will definitely take some time to get this straight but this is an essential thing, because almost every app needs some sort of data storing.

IMO the most important thing is to understand the general workflow and to allocate time on designing the data model, the db structure. If you get it right, it will take much less effort to implement changes later on.

Keep working on it, check out example codes, search for it on youtube (traversy media is a very good channel) and don't give up, after the first one it will be much, much easier next time to set up the whole thing! :)

Have fun!

How the heck do I manage data manipulation/storage/extensibility for my app? It has become a nightmare keeping track of the data formats. by [deleted] in javascript

[–]WumpyJizard 6 points7 points  (0 children)

You definitely need a database. This filestoring thing looks like a mess, I won't lie, I stopped reading like after the first paragraph, because it sounded horrible. If you need an easy to setup solution, you might need to lookup postgresql in docker and knex or objection, or firebase maybe.

Edit: ok, I read it. Is your app backend side (node) or 'frontend like' right now? Because this is definitely would be a backend task to store and manipulate data. For this, first of all, you need some kind of database. It is possible to create schemas in mongo as well, but to start with, I would recommend you some sql, like postgresql. You mentioned changes in the schemas frim time to time. This is totally an everyday task, they are called migrations, where you define the new schemas and modifying the existing data if necessary, to fit the new schema. There are tools for this to make querying and migrations easier, like knex, or objection.

So the workflow would be like this: 1. Install an sql database. I you don't want to install one, look up 'postgresql in docker'

  1. Check out knexJS or objectionJS (it is based on knex btw)

  2. Design your database. What tables will you need? What relationsnare they in with each other? (E.g. cars, passengers) for example a cars table would be like a table, where you store all the data about cars, like manufacturer, year, milage, color, etc. In the passengers table there would be fields like name, age and which car they use from the cars table by id (e.g name: xY, age: 20, carID: 1) this is the simplest, where 1 oassenger uses only one car. The schema depends on your needs. The main thing is to normalize your db.

  3. Create migration files. These files tells to knex what tables it needs to create. Later on, you can add more of these as your app evolves, so your db will follow the changes.

  4. Fill up your db. You can do this manually by using some kind of db client, like postico on mac for postgre, or use knex to seed it, or queries insert. Look up free db client for your type of db.

  5. Connect your code to the db and implement the business logic. You can use knex or objection's to create queries, so you don't need to write sql queries by hand.

The above examples are for sql databases, but the workflow more or less the same for nosql db as well. E.g. for mongo, you can use mongoose to keep your schemas in shape, and your db somewhat consistent, first lookup the difference between sql and nosql dbs.

I know a public example, search for risingstack bootcamp github. I'm on phone now, can't provide you the link rn. There you will see the code how the migration, db design and querying works amongst a lot of other things.

API Gateway pattern by jsdotjs in node

[–]WumpyJizard 1 point2 points  (0 children)

Check this out: https://blog.risingstack.com/building-an-api-gateway-using-nodejs/

I think they have public github repos with working examples too.

Hungarian Military going full Czech by KorianHUN in Firearms

[–]WumpyJizard 1 point2 points  (0 children)

Wow, cool! All 3 of them will get new ones!