datatable-axios 0.0.9 → 1.1.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/.github/workflows/publish.yml +51 -0
- package/.github/workflows/sonar.yml +28 -0
- package/.prettierignore +4 -0
- package/.prettierrc.json +8 -0
- package/.releaserc.json +16 -0
- package/CHANGELOG.md +78 -0
- package/LICENSE +20 -20
- package/Readme.md +176 -137
- package/dist/datatable-axios.cjs.js +77 -83
- package/dist/datatable-axios.esm.js +77 -83
- package/dist/datatable-axios.umd.js +86 -90
- package/eslint.config.js +29 -0
- package/package.json +78 -59
- package/sonar-project.properties +6 -0
- package/test/datatable.test.js +108 -0
- package/dist/datatable-axios.js +0 -30
- package/dist/datatable-axios.umd.cjs +0 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: Publish to npm
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
issues: write
|
|
10
|
+
pull-requests: write
|
|
11
|
+
id-token: write
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- uses: actions/setup-node@v4
|
|
20
|
+
with:
|
|
21
|
+
node-version: "24"
|
|
22
|
+
cache: "npm"
|
|
23
|
+
|
|
24
|
+
- run: npm ci
|
|
25
|
+
|
|
26
|
+
- run: npm run lint
|
|
27
|
+
|
|
28
|
+
- run: npm run format:check
|
|
29
|
+
|
|
30
|
+
- run: npm test
|
|
31
|
+
|
|
32
|
+
release:
|
|
33
|
+
needs: test
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v4
|
|
37
|
+
with:
|
|
38
|
+
fetch-depth: 0
|
|
39
|
+
|
|
40
|
+
- uses: actions/setup-node@v4
|
|
41
|
+
with:
|
|
42
|
+
node-version: "24"
|
|
43
|
+
registry-url: "https://registry.npmjs.org"
|
|
44
|
+
cache: "npm"
|
|
45
|
+
|
|
46
|
+
- run: npm ci
|
|
47
|
+
|
|
48
|
+
- run: npx semantic-release
|
|
49
|
+
env:
|
|
50
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
51
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: SonarCloud
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
types: [opened, synchronize, reopened]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
sonar:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
with:
|
|
15
|
+
fetch-depth: 0
|
|
16
|
+
|
|
17
|
+
- uses: actions/setup-node@v4
|
|
18
|
+
with:
|
|
19
|
+
node-version: "24"
|
|
20
|
+
cache: "npm"
|
|
21
|
+
|
|
22
|
+
- run: npm ci
|
|
23
|
+
|
|
24
|
+
- run: npm run test:coverage
|
|
25
|
+
|
|
26
|
+
- uses: SonarSource/sonarqube-scan-action@v6
|
|
27
|
+
env:
|
|
28
|
+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
package/.prettierignore
ADDED
package/.prettierrc.json
ADDED
package/.releaserc.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"branches": ["main"],
|
|
3
|
+
"plugins": [
|
|
4
|
+
"@semantic-release/commit-analyzer",
|
|
5
|
+
"@semantic-release/release-notes-generator",
|
|
6
|
+
"@semantic-release/npm",
|
|
7
|
+
"@semantic-release/github",
|
|
8
|
+
[
|
|
9
|
+
"@semantic-release/git",
|
|
10
|
+
{
|
|
11
|
+
"assets": ["package.json", "package-lock.json"],
|
|
12
|
+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
]
|
|
16
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file. Format is
|
|
4
|
+
based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
|
+
|
|
6
|
+
## [1.0.0] - 2026-09-06
|
|
7
|
+
|
|
8
|
+
Modernization relaunch — no public API changes.
|
|
9
|
+
|
|
10
|
+
- Add ESLint + Prettier configuration.
|
|
11
|
+
- Add unit tests (`node:test`) covering `get`/`post`/`put` with and without
|
|
12
|
+
`page`/`paginate`/`search` query parameters.
|
|
13
|
+
- Add GitHub Actions workflows for CI/publish and SonarCloud analysis.
|
|
14
|
+
- Add semantic-release configuration for automated npm publishing.
|
|
15
|
+
- Simplify `datatable.js` request methods to return the underlying
|
|
16
|
+
`window.axios` promise directly instead of wrapping it in a redundant
|
|
17
|
+
`new Promise(async ...)` executor (behavior unchanged).
|
|
18
|
+
|
|
19
|
+
## [0.0.11] - 2023-09-07
|
|
20
|
+
|
|
21
|
+
Note: not published to npm (latest published version is 0.0.10); dated from
|
|
22
|
+
the version-bump commit `6842c9b`.
|
|
23
|
+
|
|
24
|
+
- Add JSDoc comments across `datatable.js`.
|
|
25
|
+
- Fix `searchParams` variable scoping (moved from global to local scope).
|
|
26
|
+
- Change `const` to `let` for reassigned variables.
|
|
27
|
+
- Add `publish` npm script.
|
|
28
|
+
- Various README/documentation and image/branding refinements (author info,
|
|
29
|
+
npm install instructions, header meta tags, permission policy meta, OG
|
|
30
|
+
images, copy-code notification, `.vscode` gitignore entry).
|
|
31
|
+
|
|
32
|
+
## [0.0.10] - 2023-08-21
|
|
33
|
+
|
|
34
|
+
- Add documentation link to README.
|
|
35
|
+
|
|
36
|
+
## [0.0.9] - 2023-08-21
|
|
37
|
+
|
|
38
|
+
- Add license.
|
|
39
|
+
- Add pros & cons section, badge information, and general documentation to
|
|
40
|
+
README.
|
|
41
|
+
- Correct README API URL and text.
|
|
42
|
+
- Add npm website reference.
|
|
43
|
+
|
|
44
|
+
## [0.0.8] - 2023-08-20
|
|
45
|
+
|
|
46
|
+
- Add code comments and reorganize README.
|
|
47
|
+
|
|
48
|
+
## [0.0.7] - 2023-08-20
|
|
49
|
+
|
|
50
|
+
- Change package export file configuration.
|
|
51
|
+
|
|
52
|
+
## [0.0.6] - 2023-08-20
|
|
53
|
+
|
|
54
|
+
- Add `.npmignore`.
|
|
55
|
+
|
|
56
|
+
## [0.0.5] - 2023-08-20
|
|
57
|
+
|
|
58
|
+
- Add `rollup.config.js` for bundling.
|
|
59
|
+
- Add `peerDependencies` to `package.json`.
|
|
60
|
+
- Update `package.json` keywords.
|
|
61
|
+
|
|
62
|
+
## [0.0.4] - 2023-08-20
|
|
63
|
+
|
|
64
|
+
- Change all files (internal restructuring).
|
|
65
|
+
|
|
66
|
+
## [0.0.3] - 2023-08-20
|
|
67
|
+
|
|
68
|
+
- Fix: add `axios` dependency.
|
|
69
|
+
|
|
70
|
+
## [0.0.2] - 2023-08-20
|
|
71
|
+
|
|
72
|
+
- Remove unused `datatable` constructor.
|
|
73
|
+
|
|
74
|
+
## [0.0.1] - 2023-08-20
|
|
75
|
+
|
|
76
|
+
- Initial release: `datatable` class with `get`/`post`/`put` methods that
|
|
77
|
+
proxy `window.axios` requests, appending `page`/`paginate`/`search` query
|
|
78
|
+
parameters when present in the current page's URL.
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Mahmudun Nabi Kajal
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Mahmudun Nabi Kajal
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/Readme.md
CHANGED
|
@@ -1,137 +1,176 @@
|
|
|
1
|
-
# Datatable Axios
|
|
2
|
-
|
|
3
|
-
[](https://github.com/mahmudunnabikajal/datatable-axios "Go to GitHub repo")
|
|
4
|
+
[](https://www.npmjs.com/package/datatable-axios)
|
|
5
|
+
[](https://www.npmjs.com/package/datatable-axios)
|
|
6
|
+
[](#license)
|
|
7
|
+
[](https://mahmudunnabikajal.github.io/datatable-axios/ "Go to project documentation")
|
|
8
|
+
|
|
9
|
+
Datatable Axios is a simple and convenient npm package that helps you make GET, POST, and PUT requests with ease, while handling search parameters and pagination seamlessly. It's built on top of the popular Axios library, making it reliable and efficient for your data fetching needs.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# Installation
|
|
14
|
+
|
|
15
|
+
You can install Datatable Axios using npm:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install datatable-axios
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# Why Datatable Axios?
|
|
24
|
+
|
|
25
|
+
Simplify your `HTTP calls without repetition`. Say goodbye to repeating steps for every datatable request!
|
|
26
|
+
|
|
27
|
+
- **`Cons:`** Without using the library, you can achieve the same functionality in Axios which _**isn't readable & reusable**_.
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
const response = await axios.get("http://example.com/api/v1/products?page=2&paginate=25&search=we");
|
|
31
|
+
console.log(response.data);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- **`Pros:`** After using this library, you can achieve the same functionality of Axios in a _**readable & reusable way**_
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
const response = await datatable.get("products");
|
|
38
|
+
console.log(response.data);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# Usage
|
|
44
|
+
|
|
45
|
+
To get started with Datatable Axios, follow these simple steps:
|
|
46
|
+
|
|
47
|
+
- use global axios plugin setup in `axios.js` (optional)
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
import axios from "axios";
|
|
51
|
+
|
|
52
|
+
// Make the axios library globally available on the window object
|
|
53
|
+
window.axios = axios;
|
|
54
|
+
// Set your base API URL for seamless requests
|
|
55
|
+
window.axios.defaults.baseURL = "http://example.com/api/v1/";
|
|
56
|
+
|
|
57
|
+
// Other configuration here
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- Import the package at the top of your JavaScript file:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
import datatable from "datatable-axios";
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
- Initialize an instance of the Datatable class:
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
const datatable = new Datatable();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# Use of API URL:
|
|
75
|
+
|
|
76
|
+
- When you have a global `axios.js` configuration setting with baseURL, simplify calls API by using just the path:
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
const response = await datatable.get("products");
|
|
80
|
+
console.log(response.data);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
- If you're not utilizing a global `axios.js` configuration for with baseURL, include the full URL when making API calls:
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
const response = await datatable.get("http://example.com/api/v1/products");
|
|
87
|
+
console.log(response.data);
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# Use of HTTP requests:
|
|
93
|
+
|
|
94
|
+
- Perform a GET request:
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
const response = await datatable.get("url or path");
|
|
98
|
+
console.log(response.data); // Display the fetched data
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
- Perform a POST request:
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
const response = await datatable.post("url or path");
|
|
105
|
+
console.log(response.data); // Display the response data
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- Perform a PUT request:
|
|
109
|
+
|
|
110
|
+
```js
|
|
111
|
+
const response = await datatable.put("url or path");
|
|
112
|
+
console.log(response.data); // Display the updated data
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# Example of HTTP call:
|
|
118
|
+
|
|
119
|
+
- Example 1 :
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
datatable
|
|
123
|
+
.get("http://example.com/api/v1/products")
|
|
124
|
+
.then((response) => {
|
|
125
|
+
console.log("Data fetched successfully:", response.data);
|
|
126
|
+
})
|
|
127
|
+
.catch((error) => {
|
|
128
|
+
console.error("An error occurred:", error);
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
- Example 2 :
|
|
133
|
+
|
|
134
|
+
```js
|
|
135
|
+
try {
|
|
136
|
+
const response = await datatable.get("/api/v1/products");
|
|
137
|
+
console.log("Data fetched successfully:", response.data);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
console.error("An error occurred:", error);
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**`Note:`** Similar usage for POST and PUT requests
|
|
144
|
+
<!-- # Advanced Usage
|
|
145
|
+
You can also pass search parameters, pagination, and search queries to your requests:
|
|
146
|
+
|
|
147
|
+
```js
|
|
148
|
+
// Append search parameters to the URL
|
|
149
|
+
const response = await datatable.get('https://api.example.com/data', {
|
|
150
|
+
page: 1,
|
|
151
|
+
paginate: 10,
|
|
152
|
+
search: 'keyword',
|
|
153
|
+
});
|
|
154
|
+
console.log(response.data);
|
|
155
|
+
``` -->
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
# Contributing
|
|
160
|
+
|
|
161
|
+
We welcome contributions to enhance Datatable Axios! Feel free to open issues for bug reports or feature requests. If you'd like to contribute code, please fork the repository, make your changes, and submit a pull request.
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
# License
|
|
166
|
+
|
|
167
|
+
Released under [MIT License](LICENSE) by [@mahmudunnabikajal](https://github.com/mahmudunnabikajal).
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
# Author
|
|
172
|
+
|
|
173
|
+
Mahmudun Nabi Kajal<br />
|
|
174
|
+
Contact: [Linkedin](https://www.linkedin.com/in/mahmudun-nabi-kajal/), [GitHub](https://github.com/mahmudunnabikajal), [Gmail](mailto:mahmudunnabikajal), [Website](http://mahmudunnabikajal.com/)
|
|
175
|
+
|
|
176
|
+
Feel free to reach out to me for any questions or feedback! I hope Datatable Axios simplifies your data fetching process for your datatable.
|