@netacea/cloudflare 5.1.21 → 5.1.22
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/CHANGELOG.md +8 -0
- package/README.md +53 -28
- package/dist/package.json +4 -4
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 5.1.22 (2023-05-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @netacea/cloudflare
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## 5.1.21 (2023-05-12)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @netacea/cloudflare
|
package/README.md
CHANGED
|
@@ -5,37 +5,33 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/@netacea/cloudflare)
|
|
6
6
|
[](http://www.typescriptlang.org/)
|
|
7
7
|
|
|
8
|
-
`@netacea/cloudflare` is a package designed to add [Netacea](https://netacea.com) functionality to [Cloudflare
|
|
8
|
+
`@netacea/cloudflare` is a package designed to add [Netacea](https://netacea.com) functionality to [Cloudflare workers](https://workers.cloudflare.com/).
|
|
9
9
|
|
|
10
10
|
## Diagrams, Testing & Tooling
|
|
11
11
|
|
|
12
|
-
Additional documentation for
|
|
12
|
+
Additional documentation for Cloudflare can be found [here](https://github.com/Netacea/JavascriptATAIntegration/blob/main/docs/integrations/CLOUDFLARE.md).
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
16
|
### 🤠 __Wrangler__
|
|
17
17
|
|
|
18
|
-
We strongly recommend installing and using [
|
|
18
|
+
We strongly recommend installing and using [Wrangler](https://developers.cloudflare.com/workers/wrangler/) to manage your Cloudflare workers. Wrangler is a CLI tool designed to make previewing and deploying Cloudflare workers seamless.
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
`sudo chmod 777 ~/root`
|
|
22
|
-
`npm install -g @cloudflare/wrangler`
|
|
23
|
-
`sudo chmod 700 ~/root`
|
|
24
|
-
`sudo chmod -R 700 ~/root/.wrangler`
|
|
20
|
+
Installation instructions can be found [here](https://developers.cloudflare.com/workers/wrangler/install-and-update/).
|
|
25
21
|
|
|
26
|
-
Check
|
|
22
|
+
Check whether Wrangler is installed by using
|
|
27
23
|
`wrangler --help`
|
|
28
24
|
|
|
29
25
|
#### 🌻 Starting fresh
|
|
30
26
|
|
|
31
|
-
|
|
27
|
+
When using SSH for git, you will need to create a `.gitconfig` file and include the following lines
|
|
32
28
|
```
|
|
33
29
|
[url "ssh://git@github.com/"]
|
|
34
30
|
insteadOf = https://github.com
|
|
35
31
|
```
|
|
36
|
-
otherwise
|
|
32
|
+
otherwise Wrangler will fail to clone the project when using `wrangler generate`.
|
|
37
33
|
|
|
38
|
-
After installing
|
|
34
|
+
After installing Wrangler, you can pull the Netacea worker template by running the following:
|
|
39
35
|
|
|
40
36
|
```bash
|
|
41
37
|
wrangler generate netacea-cloudflare-worker https://github.com/netacea/cloudflare-worker-template-typescript
|
|
@@ -45,30 +41,30 @@ npm i @netacea/cloudflare@latest
|
|
|
45
41
|
npm run test
|
|
46
42
|
```
|
|
47
43
|
|
|
48
|
-
The tests should pass
|
|
44
|
+
The tests should pass (if they don't, please open an issue [here](https://github.com/Netacea/cloudflare-worker-template-typescript/issues)).
|
|
49
45
|
|
|
50
46
|
Follow the `README.md` in the [cloudflare-worker-template-typescript](https://github.com/Netacea/cloudflare-worker-template-typescript) repository to get this deployed.
|
|
51
47
|
|
|
52
|
-
#### ✍ Existing
|
|
48
|
+
#### ✍ Existing JavaScript worker
|
|
53
49
|
|
|
54
|
-
Run the following command to install the
|
|
50
|
+
Run the following command to install the Netacea worker
|
|
55
51
|
|
|
56
|
-
```
|
|
57
|
-
npm i @netacea/cloudflare
|
|
52
|
+
```bash
|
|
53
|
+
npm i @netacea/cloudflare
|
|
58
54
|
```
|
|
59
55
|
|
|
60
|
-
|
|
56
|
+
Import the worker
|
|
61
57
|
|
|
62
|
-
```
|
|
63
|
-
//
|
|
58
|
+
```javascript
|
|
59
|
+
// CommonJS:
|
|
64
60
|
const NetaceaCloudflare = require('@netacea/cloudflare').default
|
|
65
|
-
//
|
|
61
|
+
// ES modules:
|
|
66
62
|
import NetaceaCloudflare from '@netacea/cloudflare'
|
|
67
63
|
```
|
|
68
64
|
|
|
69
65
|
Then declare a variable for the worker.
|
|
70
66
|
|
|
71
|
-
```
|
|
67
|
+
```javascript
|
|
72
68
|
const worker = new NetaceaCloudflare({
|
|
73
69
|
apiKey: 'your-api-key',
|
|
74
70
|
secretKey: 'your-secret-key'
|
|
@@ -77,11 +73,40 @@ const worker = new NetaceaCloudflare({
|
|
|
77
73
|
|
|
78
74
|
It's best security practice to **not** commit your `apiKey` and `secretKey` to any repository.
|
|
79
75
|
|
|
80
|
-
Finally in your request handler, call worker.run(event, originRequest) where originRequest is a function that will return a response.
|
|
81
|
-
|
|
76
|
+
Finally in your request handler, call `worker.run(event, originRequest)` where `originRequest` is a function that will return a response.
|
|
77
|
+
Below are two examples of workers written in JavaScript and TypeScript:
|
|
78
|
+
|
|
79
|
+
JavaScript:
|
|
80
|
+
```javascript
|
|
81
|
+
const NetaceaCloudflare = require('@netacea/cloudflare').default
|
|
82
|
+
|
|
83
|
+
const worker = new NetaceaCloudflare({
|
|
84
|
+
apiKey: 'your-api-key',
|
|
85
|
+
secretKey: 'your-secret-key'
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
async function handleRequestWithNetacea(event) {
|
|
89
|
+
const response = await worker.run(event, originRequest)
|
|
90
|
+
event.waitUntil(worker.ingest(event.request, response))
|
|
91
|
+
return response
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function originRequest(request) {
|
|
95
|
+
// Implement custom pre-fetch logic here
|
|
96
|
+
const response = await fetch(request)
|
|
97
|
+
// Implement custom post-fetch logic here
|
|
98
|
+
return response
|
|
99
|
+
}
|
|
82
100
|
|
|
83
|
-
|
|
101
|
+
module.exports = {
|
|
102
|
+
handleRequestWithNetacea
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
TypeScript:
|
|
107
|
+
```typescript
|
|
84
108
|
import NetaceaCloudflare from '@netacea/cloudflare'
|
|
109
|
+
|
|
85
110
|
const worker = new NetaceaCloudflare({
|
|
86
111
|
apiKey: 'your-api-key',
|
|
87
112
|
secretKey: 'your-secret-key'
|
|
@@ -103,8 +128,8 @@ async function originRequest(request: Request): Promise<Response> {
|
|
|
103
128
|
|
|
104
129
|
## ⬆ Updating
|
|
105
130
|
|
|
131
|
+
Updating the Netacea Cloudflare package can be done with the following command:
|
|
132
|
+
|
|
106
133
|
```bash
|
|
107
|
-
npm i @netacea/cloudflare@latest
|
|
134
|
+
npm i @netacea/cloudflare@latest
|
|
108
135
|
```
|
|
109
|
-
|
|
110
|
-
This will update the netacea module to the latest version.
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netacea/cloudflare",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.22",
|
|
4
4
|
"description": "Netacea Cloudflare CDN Integration",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@netacea/kinesisingest": "^1.4.
|
|
20
|
-
"@netacea/netaceaintegrationbase": "^1.16.
|
|
19
|
+
"@netacea/kinesisingest": "^1.4.21",
|
|
20
|
+
"@netacea/netaceaintegrationbase": "^1.16.20",
|
|
21
21
|
"jose": "^4.11.2"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"tsconfig-paths": "^3.9.0",
|
|
35
35
|
"typescript": "^3.9.7"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "9ddcdbfeee58bdae09fb5034378eb76e8eb53e72"
|
|
38
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netacea/cloudflare",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.22",
|
|
4
4
|
"description": "Netacea Cloudflare CDN Integration",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@netacea/kinesisingest": "^1.4.
|
|
20
|
-
"@netacea/netaceaintegrationbase": "^1.16.
|
|
19
|
+
"@netacea/kinesisingest": "^1.4.21",
|
|
20
|
+
"@netacea/netaceaintegrationbase": "^1.16.20",
|
|
21
21
|
"jose": "^4.11.2"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"tsconfig-paths": "^3.9.0",
|
|
35
35
|
"typescript": "^3.9.7"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "9ddcdbfeee58bdae09fb5034378eb76e8eb53e72"
|
|
38
38
|
}
|