reqforge 0.1.0 → 0.2.0

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.
package/README.md CHANGED
@@ -8,6 +8,33 @@ A lightweight, flexible HTTP client library with request interception, automatic
8
8
  npm install reqforge
9
9
  ```
10
10
 
11
+ ## Quick Start
12
+
13
+ ```javascript
14
+ const { config } = require('reqforge');
15
+
16
+ // Get the base URL for API requests
17
+ const baseURL = config.getBaseURL();
18
+ console.log(baseURL); // https://api.example.com/v1
19
+
20
+ // Merge custom configuration
21
+ const customConfig = config.mergeConfig({
22
+ timeout: 10000,
23
+ headers: {
24
+ 'Authorization': 'Bearer your-token'
25
+ }
26
+ });
27
+ ```
28
+
29
+ ## Configuration
30
+
31
+ The `config` module provides:
32
+
33
+ - `getBaseURL()` - Get the base URL for API requests
34
+ - `API_VERSION` - Current API version
35
+ - `defaultConfig` - Default configuration object
36
+ - `mergeConfig(customConfig)` - Merge custom configuration with defaults
37
+
11
38
  ## License
12
39
 
13
40
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reqforge",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "A lightweight, flexible HTTP client library with request interception, automatic retry, and logging capabilities, designed for modern web applications.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/config.js ADDED
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Configuration module for ReqForge
3
+ * @module config
4
+ */
5
+
6
+ const API_VERSION = 'v1';
7
+
8
+ /**
9
+ * Get the base URL for API requests
10
+ * @returns {string} The base URL with API version
11
+ */
12
+ function getBaseURL() {
13
+ return `https://api.example.com/${API_VERSION}`;
14
+ }
15
+
16
+ /**
17
+ * Default configuration for requests
18
+ */
19
+ const defaultConfig = {
20
+ baseURL: getBaseURL(),
21
+ timeout: 5000,
22
+ headers: {
23
+ 'Content-Type': 'application/json'
24
+ }
25
+ };
26
+
27
+ /**
28
+ * Merge custom configuration with defaults
29
+ * @param {Object} customConfig - Custom configuration to merge
30
+ * @returns {Object} Merged configuration
31
+ */
32
+ function mergeConfig(customConfig = {}) {
33
+ return {
34
+ ...defaultConfig,
35
+ ...customConfig,
36
+ headers: {
37
+ ...defaultConfig.headers,
38
+ ...(customConfig.headers || {})
39
+ }
40
+ };
41
+ }
42
+
43
+ module.exports = {
44
+ getBaseURL,
45
+ API_VERSION,
46
+ defaultConfig,
47
+ mergeConfig
48
+ };
package/src/index.js CHANGED
@@ -3,4 +3,8 @@
3
3
  * @module reqforge
4
4
  */
5
5
 
6
- module.exports = {};
6
+ const config = require('./config');
7
+
8
+ module.exports = {
9
+ config
10
+ };