cloudflare.js 945 B

12345678910111213141516171819202122232425262728293031323334353637
  1. var reqwest = require('reqwest');
  2. var assign = require('react/lib/Object.assign');
  3. function makeCall(path) {
  4. return function() {
  5. var domain = null;
  6. var options = {};
  7. if(arguments.length > 0) {
  8. domain = arguments[0];
  9. }
  10. if(arguments.length > 1) {
  11. options = arguments[1];
  12. }
  13. return reqwest({
  14. url: '/api',
  15. data: assign({a: path, z: domain}, options),
  16. method: 'POST'
  17. });
  18. };
  19. }
  20. module.exports = {
  21. domains: makeCall('zone_load_multi'),
  22. settings: makeCall('zone_settings'),
  23. records: makeCall('rec_load_all'),
  24. recordAdd: makeCall('rec_new'),
  25. recordEdit: makeCall('rec_edit'),
  26. recordDelete: function(domain, id) {
  27. return makeCall('rec_delete')(domain, {id: id});
  28. },
  29. setDevelopmentMode: function(domain, toggle) {
  30. return makeCall('devmode')(domain, {v: toggle ? 1 : 0});
  31. },
  32. purgeCache: function(domain) {
  33. return makeCall('fpurge_ts')(domain, {v: 1});
  34. }
  35. };