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.

34 lines
784 B

  1. const fs = require('fs');
  2. const sql = require('../utils/sql');
  3. module.exports=
  4. {
  5. main: function()
  6. {
  7. sql.getSiteMap().then(function(result)
  8. {
  9. var buf = Buffer.from(result, 'utf8');
  10. var path = '../sitemap.txt';
  11. fs.open(path, 'w', function(error, fd)
  12. {
  13. if(error)
  14. throw 'could not open file: ' + error;
  15. fs.write(fd, buf, 0, buf.length, null, function(err)
  16. {
  17. if(err)
  18. throw "error writing file: " + err;
  19. fs.close(fd, function()
  20. {
  21. console.log("Updated Sitemap");
  22. })
  23. });
  24. });
  25. });
  26. }
  27. }