5.2.33 • Published 10 days ago

@netacea/cloudflare v5.2.33

Weekly downloads
3
License
ISC
Repository
-
Last release
10 days ago

Netacea Cloudflare

Netacea Header

npm   TypeScript

@netacea/cloudflare is a package designed to add Netacea functionality to Cloudflare workers.

Installation

🤠 Wrangler

We strongly recommend installing and using Wrangler to manage your Cloudflare workers. Wrangler is a CLI tool designed to make previewing and deploying Cloudflare workers seamless.

Installation instructions can be found here.

Check whether Wrangler is installed by using wrangler --help

🌻 Starting fresh

When using SSH for git, you will need to create a .gitconfig file and include the following lines

  [url "ssh://git@github.com/"]
  insteadOf = https://github.com

otherwise Wrangler will fail to clone the project when using wrangler generate.

After installing Wrangler, you can pull the Netacea worker template by running the following:

wrangler generate netacea-cloudflare-worker https://github.com/netacea/cloudflare-worker-template-typescript
cd netacea-cloudflare-worker
npm i
npm i @netacea/cloudflare@latest
npm run test

The tests should pass (if they don't, please open an issue here).

Follow the README.md in the cloudflare-worker-template-typescript repository to get this deployed.

✍ Existing JavaScript worker

Run the following command to install the Netacea worker

npm i @netacea/cloudflare

Import the worker

// CommonJS:
const NetaceaCloudflare = require('@netacea/cloudflare').default
// ES modules:
import NetaceaCloudflare from '@netacea/cloudflare'

Then declare a variable for the worker.

const worker = new NetaceaCloudflare({
  apiKey: 'your-api-key',
  secretKey: 'your-secret-key'
})

It's best security practice to not commit your apiKey and secretKey to any repository.

Finally in your request handler, call worker.run(event, originRequest) where originRequest is a function that will return a response. Below are two examples of workers written in JavaScript and TypeScript:

JavaScript:

const NetaceaCloudflare = require('@netacea/cloudflare').default

const worker = new NetaceaCloudflare({
  apiKey: 'your-api-key',
  secretKey: 'your-secret-key'
})

async function handleRequestWithNetacea(event) {
  const response = await worker.run(event, originRequest)
  event.waitUntil(worker.ingest(event.request, response))
  return response
}

async function originRequest(request) {
  // Implement custom pre-fetch logic here
  const response = await fetch(request)
  // Implement custom post-fetch logic here
  return response
}

module.exports = {
  handleRequestWithNetacea
}

TypeScript:

import NetaceaCloudflare from '@netacea/cloudflare'

const worker = new NetaceaCloudflare({
  apiKey: 'your-api-key',
  secretKey: 'your-secret-key'
})

export async function handleRequestWithNetacea(event: FetchEvent): Promise<Response> {
  const response = await worker.run(event, originRequest)
  event.waitUntil(worker.ingest(event.request, response))
  return response
}

async function originRequest(request: Request): Promise<Response> {
  // Implement custom pre-fetch logic here
  const response = await fetch(request)
  // Implement custom post-fetch logic here
  return response
}

⬆ Updating

Updating the Netacea Cloudflare package can be done with the following command:

npm i @netacea/cloudflare@latest
5.2.33

10 days ago

5.2.32

16 days ago

5.2.31

23 days ago

5.2.30

24 days ago

5.2.29

1 month ago

5.2.28

1 month ago

5.2.27

1 month ago

5.2.26

1 month ago

5.2.25

1 month ago

5.2.24

1 month ago

5.2.23

1 month ago

5.2.22

1 month ago

5.2.21

2 months ago

5.2.20

2 months ago

5.2.19

2 months ago

5.2.18

2 months ago

5.2.17

2 months ago

5.2.16

2 months ago

5.2.15

2 months ago

5.2.14

2 months ago

5.2.13

2 months ago

5.2.12

2 months ago

5.2.11

2 months ago

5.2.10

2 months ago

5.2.9

2 months ago

5.2.8

2 months ago

5.2.7

2 months ago

5.2.6

2 months ago

5.2.5

2 months ago

5.2.4

2 months ago

5.2.3

2 months ago

5.2.2

2 months ago

5.2.1

3 months ago

5.2.0

3 months ago

5.1.96

3 months ago

5.1.95

3 months ago

5.1.94

3 months ago

5.1.92

3 months ago

5.1.93

3 months ago

5.1.91

3 months ago

5.1.90

3 months ago

5.1.89

3 months ago

5.1.88

3 months ago

5.1.87

3 months ago

5.1.86

4 months ago

5.1.85

4 months ago

5.1.84

4 months ago

5.1.83

4 months ago

5.1.82

4 months ago

5.1.81

4 months ago

5.1.80

5 months ago

5.1.79

5 months ago

5.1.78

5 months ago

5.1.77

5 months ago

5.1.76

5 months ago

5.1.70

7 months ago

5.1.75

6 months ago

5.1.74

6 months ago

5.1.73

6 months ago

5.1.72

6 months ago

5.1.71

6 months ago

5.1.69

7 months ago

5.1.68

7 months ago

5.1.67

7 months ago

5.1.66

7 months ago

5.1.65

7 months ago

5.1.64

8 months ago

5.1.63

8 months ago

5.1.62

8 months ago

5.1.61

8 months ago

5.1.60

8 months ago

5.1.59

8 months ago

5.1.58

8 months ago

5.1.57

8 months ago

5.1.56

9 months ago

5.1.55

9 months ago

5.1.54

9 months ago

5.1.53

9 months ago

5.1.52

9 months ago

5.1.51

9 months ago

5.1.50

9 months ago

5.1.49

10 months ago

5.1.48

10 months ago

5.1.47

10 months ago

5.1.46

10 months ago

5.1.45

10 months ago

5.1.44

10 months ago

5.1.43

10 months ago

5.1.42

10 months ago

5.1.41

10 months ago

5.1.40

11 months ago

5.1.39

11 months ago

5.1.38

11 months ago

5.1.37

11 months ago

5.1.36

11 months ago

5.1.35

11 months ago

5.1.34

11 months ago

5.1.33

11 months ago

5.1.32

11 months ago

5.1.31

11 months ago

5.1.30

11 months ago

5.1.29

11 months ago

5.1.28

11 months ago

5.1.27

11 months ago

5.1.26

11 months ago

5.1.25

12 months ago

5.1.24

12 months ago

5.1.23

12 months ago

5.1.22

12 months ago

5.1.21

12 months ago

5.1.20

12 months ago

5.1.19

12 months ago

5.1.18

1 year ago

5.1.17

1 year ago

5.1.5

1 year ago

5.1.4

1 year ago

5.1.3

1 year ago

5.1.2

1 year ago

5.1.16

1 year ago

5.1.15

1 year ago

5.1.14

1 year ago

5.1.13

1 year ago

5.1.12

1 year ago

5.1.11

1 year ago

5.1.10

1 year ago

5.1.9

1 year ago

5.1.8

1 year ago

5.1.7

1 year ago

5.1.6

1 year ago

5.1.1

1 year ago

5.1.0

1 year ago

4.1.0

1 year ago

4.0.3

1 year ago

4.0.2

1 year ago

4.0.1

2 years ago

1.6.13

2 years ago

1.6.11

2 years ago

1.6.10

2 years ago

1.6.12

2 years ago

1.6.4

2 years ago

1.6.3

2 years ago

1.6.9

2 years ago

1.6.8

2 years ago

1.6.7

2 years ago

1.6.6

2 years ago

1.6.5

2 years ago

1.6.2

2 years ago

1.6.1

2 years ago

1.5.3

2 years ago

1.6.0

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago