Lightweight node app to use in place of plex to self host your video and movie collections. Running on just under 50MB of ram this is ideal for people looking to host videos on minimal hardware.
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.

43 lines
1.1 KiB

  1. /** Used to read and write files from disk */
  2. const fs = require('fs');
  3. module.exports =
  4. {
  5. syncEnv: function()
  6. {
  7. const envVars = ["PORT", "SESSION_SECRET", "SERVER_URL", "PRIVATE_DIR", "PUBLIC_DIR"];
  8. const data = envVars.map(function(envVar) {
  9. return `${envVar}=${process.env[envVar]}`
  10. }).join("\r\n");
  11. fs.writeFile('.env', data, 'utf8', function() {
  12. console.log("Wrote to .env file");
  13. });
  14. },
  15. writeJSONToFile: function(fileName, jsonObject)
  16. {
  17. const json = JSON.stringify(jsonObject, null, 4);
  18. fs.writeFile(fileName, json, 'utf8', function()
  19. {
  20. console.log("Wrote to " + fileName);
  21. });
  22. },
  23. /**
  24. *
  25. * @param fileName
  26. * @returns {any}
  27. */
  28. getFileAsJSON: function(fileName)
  29. {
  30. return JSON.parse(module.exports.getFile(fileName));
  31. },
  32. getFile: function(filename)
  33. {
  34. return fs.readFileSync(filename, 'utf8');
  35. }
  36. };