humanizedtext 0.1.2 → 0.1.3

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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/index.js +9 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -51,7 +51,7 @@ const client = new HumanizedTextClient({
51
51
  ```js
52
52
  const client = new HumanizedTextClient({
53
53
  apiKey: "YOUR_API_KEY",
54
- baseUrl: "https://api.humanizedtext.pro/api/v1",
54
+ baseUrl: "https://humanizedtext.pro/api/v1",
55
55
  timeout: 60000,
56
56
  });
57
57
  ```
@@ -59,7 +59,7 @@ const client = new HumanizedTextClient({
59
59
  | Option | Type | Required | Default | Description |
60
60
  | --------- | -------- | -------- | -------------------------------------- | ------------------------------- |
61
61
  | `apiKey` | `string` | Yes | - | HumanizedText API key |
62
- | `baseUrl` | `string` | No | `https://api.humanizedtext.pro/api/v1` | API base URL |
62
+ | `baseUrl` | `string` | No | `https://humanizedtext.pro/api/v1` | API base URL |
63
63
  | `timeout` | `number` | No | `60000` | Request timeout in milliseconds |
64
64
 
65
65
  ## API Methods
package/index.js CHANGED
@@ -10,14 +10,21 @@ class HumanizedTextAPIError extends Error {
10
10
  class HumanizedTextClient {
11
11
  constructor({
12
12
  apiKey,
13
- baseUrl = "https://api.humanizedtext.pro/api/v1",
13
+ baseUrl,
14
14
  timeout = 60000,
15
15
  }) {
16
16
  if (!apiKey) {
17
17
  throw new Error("apiKey is required");
18
18
  }
19
+ const isDev = typeof process !== "undefined" && (
20
+ process.env.NODE_ENV === "development" ||
21
+ process.env.NODE_ENV === "test" ||
22
+ process.env.HUMANIZEDTEXT_DEV === "true" ||
23
+ process.env.LOCAL_DEV === "true"
24
+ );
25
+ const defaultUrl = isDev ? "http://localhost:3000/api/v1" : "https://humanizedtext.pro/api/v1";
19
26
  this.apiKey = apiKey;
20
- this.baseUrl = baseUrl.replace(/\/$/, "");
27
+ this.baseUrl = (baseUrl || defaultUrl).replace(/\/$/, "");
21
28
  this.timeout = timeout;
22
29
  }
23
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "humanizedtext",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Official JavaScript SDK for HumanizedText API",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",