cloudflare.js 1.0 KB

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