ncloud.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. class Query {
  2. className = "";
  3. constructor(className) {
  4. this.className = className;
  5. }
  6. async getAll() {
  7. let response = await fetch(
  8. "http://1.94.237.145:1338/parsecyx/classes/" + this.className,
  9. {
  10. headers: {
  11. accept: "*/*",
  12. "accept-language":
  13. "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,zh-TW;q=0.5,ja;q=0.4",
  14. "if-none-match": 'W/"f36-Q0ech+Jn3bu0uYx1n7/k1+XDYr0"',
  15. "x-parse-application-id": "cyx",
  16. },
  17. referrer: "http://127.0.0.1:4040/",
  18. referrerPolicy: "strict-origin-when-cross-origin",
  19. body: null,
  20. method: "GET",
  21. mode: "cors",
  22. credentials: "omit",
  23. }
  24. );
  25. let json = [];
  26. if (response) {
  27. json = await response.json();
  28. }
  29. return json.results || [];
  30. }
  31. async getBy(id) {
  32. let response = await fetch(
  33. "http://1.94.237.145:1338/parsecyx/classes/" + this.className + "/" + id,
  34. {
  35. headers: {
  36. accept: "*/*",
  37. "accept-language":
  38. "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,zh-TW;q=0.5,ja;q=0.4",
  39. "if-none-match": 'W/"f36-Q0ech+Jn3bu0uYx1n7/k1+XDYr0"',
  40. "x-parse-application-id": "cyx",
  41. },
  42. referrer: "http://127.0.0.1:4040/",
  43. referrerPolicy: "strict-origin-when-cross-origin",
  44. body: null,
  45. method: "GET",
  46. mode: "cors",
  47. credentials: "omit",
  48. }
  49. );
  50. let json = {};
  51. if (response) {
  52. json = await response.json();
  53. }
  54. return json || null;
  55. }
  56. }
  57. class Insert {
  58. className = "";
  59. constructor(className) {
  60. this.className = className;
  61. }
  62. async addUser(info) {
  63. if (info.username) {
  64. method = "";
  65. }
  66. let body = JSON.stringify(info);
  67. let response = await fetch("http://1.94.237.145:1338/parsecyx/users", {
  68. headers: {
  69. accept: "*/*",
  70. "accept-language":
  71. "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,zh-TW;q=0.5,ja;q=0.4",
  72. "content-type": "text/plain",
  73. },
  74. referrer: "http://127.0.0.1:4040/",
  75. referrerPolicy: "strict-origin-when-cross-origin",
  76. // body: '{"username":"test","password":"test","email":"test@qq.com","phoneNumber":"10086","sex":"男","age":"18","_ApplicationId":"cyx","_ClientVersion":"js3.4.2","_MasterKey":"cyxmk","_InstallationId":"111053ea-8bfc-4dfc-8818-df34dd45d6b0"}',
  77. body: body,
  78. method: method,
  79. mode: "cors",
  80. credentials: "omit",
  81. });
  82. }
  83. }
  84. module.exports.Query = Query;