Personal blog written from scratch using Node.js, Bootstrap, and MySQL. https://jrtechs.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.0 KiB

  1. const utils = require('../utils/utils');
  2. /**
  3. * @author Jeffery Russell 11-24-18
  4. *
  5. * @type {{main: module.exports.main}}
  6. */
  7. module.exports=
  8. {
  9. /**
  10. * Verifies the contents of the config file
  11. * and returns it. If the config is incomplete,
  12. * it terminates the program.
  13. *
  14. * @returns {*|any}
  15. */
  16. getConfig: function()
  17. {
  18. const configContents = ["PORT", "SESSION_SECRET",
  19. "SQL_HOST", "SQL_DATABASE", "SQL_PASSWORD",
  20. "CAPTCHA_SECRET", "GMAIL_ACCOUNT", "EMAIL_PASSWORD",
  21. "DESTINATION_EMAIL"];
  22. var config = utils.getFileAsJSON("./config.json");
  23. for(var i = 0; i < configContents.length; i++)
  24. {
  25. if(!config.hasOwnProperty(configContents[i]))
  26. {
  27. console.log("Missing config property: " + configContents[i]);
  28. process.exit(1);
  29. }
  30. }
  31. return config;
  32. }
  33. }