6.0.18 • Published 12 months ago

@netacea/cloudflare v6.0.18

Weekly downloads
3
License
ISC
Repository
-
Last release
12 months 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
6.0.18

12 months ago

6.0.17

12 months ago

6.0.16

12 months ago

6.0.15

12 months ago

6.0.14

1 year ago

6.0.13

1 year ago

6.0.12

1 year ago

6.0.11

1 year ago

6.0.10

1 year ago

6.0.9

1 year ago

6.0.8

1 year ago

6.0.7

1 year ago

6.0.6

1 year ago

6.0.1

1 year ago

6.0.3

1 year ago

6.0.2

1 year ago

6.0.5

1 year ago

6.0.4

1 year ago

5.2.60

1 year ago

5.2.61

1 year ago

5.2.59

1 year ago

5.2.58

1 year ago

5.2.57

1 year ago

5.2.56

1 year ago

5.2.55

1 year ago

5.2.54

1 year ago

5.2.53

1 year ago

5.2.52

1 year ago

5.2.51

1 year ago

5.2.50

1 year ago

5.2.49

1 year ago

5.2.48

1 year ago

5.2.47

1 year ago

5.2.46

1 year ago

5.2.45

1 year ago

5.2.44

1 year ago

5.2.43

1 year ago

5.2.42

1 year ago

5.2.41

1 year ago

5.2.40

1 year ago

5.2.39

1 year ago

5.2.38

1 year ago

5.2.37

1 year ago

5.2.36

1 year ago

5.2.35

1 year ago

5.2.34

1 year ago

5.2.33

1 year ago

5.2.32

1 year ago

5.2.31

1 year ago

5.2.30

1 year ago

5.2.29

1 year ago

5.2.28

1 year ago

5.2.27

2 years ago

5.2.26

2 years ago

5.2.25

2 years ago

5.2.24

2 years ago

5.2.23

2 years ago

5.2.22

2 years ago

5.2.21

2 years ago

5.2.20

2 years ago

5.2.19

2 years ago

5.2.18

2 years ago

5.2.17

2 years ago

5.2.16

2 years ago

5.2.15

2 years ago

5.2.14

2 years ago

5.2.13

2 years ago

5.2.12

2 years ago

5.2.11

2 years ago

5.2.10

2 years ago

5.2.9

2 years ago

5.2.8

2 years ago

5.2.7

2 years ago

5.2.6

2 years ago

5.2.5

2 years ago

5.2.4

2 years ago

5.2.3

2 years ago

5.2.2

2 years ago

5.2.1

2 years ago

5.2.0

2 years ago

5.1.96

2 years ago

5.1.95

2 years ago

5.1.94

2 years ago

5.1.92

2 years ago

5.1.93

2 years ago

5.1.91

2 years ago

5.1.90

2 years ago

5.1.89

2 years ago

5.1.88

2 years ago

5.1.87

2 years ago

5.1.86

2 years ago

5.1.85

2 years ago

5.1.84

2 years ago

5.1.83

2 years ago

5.1.82

2 years ago

5.1.81

2 years ago

5.1.80

2 years ago

5.1.79

2 years ago

5.1.78

2 years ago

5.1.77

2 years ago

5.1.76

2 years ago

5.1.70

2 years ago

5.1.75

2 years ago

5.1.74

2 years ago

5.1.73

2 years ago

5.1.72

2 years ago

5.1.71

2 years ago

5.1.69

2 years ago

5.1.68

2 years ago

5.1.67

2 years ago

5.1.66

2 years ago

5.1.65

2 years ago

5.1.64

2 years ago

5.1.63

2 years ago

5.1.62

2 years ago

5.1.61

2 years ago

5.1.60

2 years ago

5.1.59

2 years ago

5.1.58

2 years ago

5.1.57

2 years ago

5.1.56

2 years ago

5.1.55

2 years ago

5.1.54

2 years ago

5.1.53

2 years ago

5.1.52

2 years ago

5.1.51

2 years ago

5.1.50

2 years ago

5.1.49

2 years ago

5.1.48

2 years ago

5.1.47

2 years ago

5.1.46

2 years ago

5.1.45

2 years ago

5.1.44

2 years ago

5.1.43

2 years ago

5.1.42

2 years ago

5.1.41

2 years ago

5.1.40

2 years ago

5.1.39

2 years ago

5.1.38

2 years ago

5.1.37

2 years ago

5.1.36

2 years ago

5.1.35

2 years ago

5.1.34

2 years ago

5.1.33

2 years ago

5.1.32

2 years ago

5.1.31

2 years ago

5.1.30

2 years ago

5.1.29

2 years ago

5.1.28

2 years ago

5.1.27

2 years ago

5.1.26

2 years ago

5.1.25

2 years ago

5.1.24

2 years ago

5.1.23

2 years ago

5.1.22

2 years ago

5.1.21

2 years ago

5.1.20

2 years ago

5.1.19

2 years ago

5.1.18

2 years ago

5.1.17

2 years ago

5.1.5

3 years ago

5.1.4

3 years ago

5.1.3

3 years ago

5.1.2

3 years ago

5.1.16

2 years ago

5.1.15

2 years ago

5.1.14

2 years ago

5.1.13

2 years ago

5.1.12

3 years ago

5.1.11

3 years ago

5.1.10

3 years ago

5.1.9

3 years ago

5.1.8

3 years ago

5.1.7

3 years ago

5.1.6

3 years ago

5.1.1

3 years ago

5.1.0

3 years ago

4.1.0

3 years ago

4.0.3

3 years ago

4.0.2

3 years ago

4.0.1

3 years ago

1.6.13

3 years ago

1.6.11

3 years ago

1.6.10

3 years ago

1.6.12

3 years ago

1.6.4

3 years ago

1.6.3

3 years ago

1.6.9

3 years ago

1.6.8

3 years ago

1.6.7

3 years ago

1.6.6

3 years ago

1.6.5

3 years ago

1.6.2

3 years ago

1.6.1

3 years ago

1.5.3

4 years ago

1.6.0

3 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago