@quillsql/node 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,8 +12,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const axios_1 = __importDefault(require("axios"));
15
16
  /** This client is currently not used but is a good design pratice */
16
- const node_fetch_1 = __importDefault(require("node-fetch"));
17
17
  class QuillServerClient {
18
18
  constructor(privateKey) {
19
19
  this.baseUrl = "";
@@ -21,12 +21,7 @@ class QuillServerClient {
21
21
  }
22
22
  postQuill(route, payload) {
23
23
  return __awaiter(this, void 0, void 0, function* () {
24
- const response = yield (0, node_fetch_1.default)(`${this.baseUrl}/${route}`, {
25
- method: "POST",
26
- headers: Object.assign(Object.assign({}, this.config.headers), { "Content-Type": "application/json" }),
27
- body: JSON.stringify(payload),
28
- });
29
- return response.json();
24
+ return axios_1.default.post(`${this.baseUrl}/${route}`, payload, this.config);
30
25
  });
31
26
  }
32
27
  }
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const CachedPools_1 = require("./db/CachedPools");
16
- const node_fetch_1 = __importDefault(require("node-fetch"));
16
+ const axios_1 = __importDefault(require("axios"));
17
17
  require("dotenv/config");
18
18
  const RunQueryProcesses_1 = require("./utils/RunQueryProcesses");
19
19
  const HOST = process.env.ENV === "development"
@@ -90,13 +90,8 @@ class QuillClass {
90
90
  }
91
91
  postQuill(path, payload) {
92
92
  return __awaiter(this, void 0, void 0, function* () {
93
- const response = yield (0, node_fetch_1.default)(`${this.baseUrl}/sdk/${path}`, {
94
- method: "POST",
95
- headers: this.config.headers,
96
- body: JSON.stringify(payload),
97
- });
98
- const data = yield response.json();
99
- return data;
93
+ const response = yield axios_1.default.post(`${this.baseUrl}/sdk/${path}`, payload, this.config);
94
+ return response.data;
100
95
  });
101
96
  }
102
97
  close() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillsql/node",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Quill's client SDK for node backends.",
5
5
  "main": "dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -26,8 +26,8 @@
26
26
  "typescript": "^5.3.3"
27
27
  },
28
28
  "dependencies": {
29
+ "axios": "^1.6.5",
29
30
  "dotenv": "^16.3.1",
30
- "node-fetch": "^3.3.2",
31
31
  "pg": "^8.11.3",
32
32
  "redis": "^4.6.12",
33
33
  "ts-jest": "^29.1.1"
@@ -1,5 +1,6 @@
1
+ import axios from "axios";
2
+
1
3
  /** This client is currently not used but is a good design pratice */
2
- import fetch from "node-fetch";
3
4
 
4
5
  class QuillServerClient {
5
6
  private baseUrl: string;
@@ -15,15 +16,7 @@ class QuillServerClient {
15
16
  }
16
17
 
17
18
  public async postQuill(route: string, payload: any): Promise<any> {
18
- const response = await fetch(`${this.baseUrl}/${route}`, {
19
- method: "POST",
20
- headers: {
21
- ...this.config.headers,
22
- "Content-Type": "application/json",
23
- },
24
- body: JSON.stringify(payload),
25
- });
26
- return response.json();
19
+ return axios.post(`${this.baseUrl}/${route}`, payload, this.config);
27
20
  }
28
21
  }
29
22
 
package/src/index.ts CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  QuillQueryParams,
7
7
  } from "./models/Quill";
8
8
  import { CachedPool } from "./db/CachedPools";
9
- import fetch from "node-fetch";
9
+ import axios from "axios";
10
10
  import "dotenv/config";
11
11
  import {
12
12
  getTableSchema,
@@ -131,13 +131,12 @@ export default class QuillClass {
131
131
  path: string,
132
132
  payload: any
133
133
  ): Promise<QuillClientResponse> {
134
- const response = await fetch(`${this.baseUrl}/sdk/${path}`, {
135
- method: "POST",
136
- headers: this.config.headers,
137
- body: JSON.stringify(payload),
138
- });
139
- const data = await response.json();
140
- return data as QuillClientResponse;
134
+ const response = await axios.post(
135
+ `${this.baseUrl}/sdk/${path}`,
136
+ payload,
137
+ this.config
138
+ );
139
+ return response.data;
141
140
  }
142
141
 
143
142
  public async close() {