Spaceface16518 / strat-collector

Combs through a specific subreddit for posts with over a certain threshold in comments. It then adds them to a database.
MIT License
2 stars 0 forks source link

Node App.js command not working #7

Closed Spaceface16518 closed 6 years ago

Spaceface16518 commented 6 years ago

While executing routine local tests, I encountered a problem in launch.js. For whatever reason, local tests seem to be breaking at this point. The line says

node app.js

It's nothing special, and it is not something simple like "I'm not building my code before I launch it".

Spaceface16518 commented 6 years ago

After adding in some line-by-line checkpoints (commit 8bd2c9a) test results show that checkpoint number 13 was not reached before the error was thrown. Checkpoint 12 also fired before the error was thrown. In this sense I have isolated the error to be in the command

node app.js

In the error text there were references to missing credentials. Here is the full error statement:
Error: Missing credentials passed to snoowrap constructor. You must pass an object containing
either (a) userAgent, clientId, clientSecret, and refreshToken properties, (b) userAgent and
accessToken properties, or (c) userAgent, clientId, clientSecret, username, and password
properties. For information, please read the docs at https://not-an-aardvark.github.i
/snoowrap/.
at new snoowrap (/Users/AMRIT/GitHub/strat-collector/node_modules/snoowrap/dist/snoowrap.js:151:13)
    at Object.<anonymous> (/Users/AMRIT/GitHub/strat-collector/app.js:10:12)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Function.Module.runMain (module.js:701:10)
    at startup (bootstrap_node.js:193:16)
    at bootstrap_node.js:617:3

As you can see, there is a lot of references to credentials. This got me thinking. Since the collector env cofigure module has not yet been configured, the app can't really work. It requires (not node require, english require) an env file containing environmental variables so that the bot knows where to look for these reddit posts and the sort. Since the nature of open source code is public, it is unsafe to commit credentials. Therefore, when local testing, you must include an environmental folder in the app. As soon as I connect the two modules (or maybe integrate them rather than having them as two separate repos) the first testing release can happen. This program is almost finished, it just needs a little push :).

In summary, the error was not with the script, but with the JavaScript file itself. Code kept calling env variables that didn't exist. You must add a env file before locally testing until the env-configure module is connected.