cloudworker-tls-no-crypto
node.js runner for Cloudflare Workers with TLS, but without crypto
Last updated 3 months ago by artskydj .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install cloudworker-tls-no-crypto 
SYNC missed versions from official npm registry.

cloudworker-tls-no-crypto

CircleCI

This repo is based on @supermari0's repo, which is based on @dollarshaveclub's repo.


Cloudworker allows you to run Cloudflare Worker scripts locally.

Installing

Install via NPM:

npm install -g cloudworker-tls-no-crypto

Package Usage

const Cloudworker = require('cloudworker-tls-no-crypto')

const simpleScript = `addEventListener('fetch', event => {
    event.respondWith(new Response('hello', { status: 200 }))
})`

const req = new Cloudworker.Request('https://myfancywebsite.com/someurl')
const cw = new Cloudworker(simpleScript)
cw.dispatch(req).then(res => {
    console.log(`Response Status: ${res.status}`)
    res.text().then(body => {
        console.log(`Response Body: ${body}`)
    })
})

CLI Usage

Usage: cloudworker [options] <file>

Options:
  -p, --port <port>                   Port (default: 3000)
  -d, --debug                         Debug
  -s, --kv-set [variable.key=value]   Binds variable to a local implementation of Workers KV and sets key to value (default: [])
  -f, --kv-file [variable=path]       Set the filepath for value peristence for the local implementation of Workers KV (default: [])
  -w, --wasm [variable=path]          Binds variable to wasm located at path (default: [])
  -c, --enable-cache                  Enables cache <BETA>
  -r, --watch                         Watch the worker script and restart the worker when changes are detected
  --tls-key <tlsKey>                  Optional. Path to encryption key for serving requests with TLS enabled. Must specify --tls-cert when using this option.
  --tls-cert <tlsCert>                Optional. Path to certificate for serving requests with TLS enabled. Must specify --tls-key when using this option.
  --https-port <httpsPort>            Optional. Port to listen on for HTTPS requests. Must specify --tls-cert and --tls-key when using this option. May not be the same value as --port.
  -h, --help                          output usage information

Simple

cloudworker example/example.js
curl localhost:3000/
cloudworker --debug example/example.js
curl localhost:3000/

Workers KV

cloudworker --debug --kv-set KeyValueStore.key=value --kv-set KeyValueStore.hello=world example/example-kv.js
curl localhost:3000/

Workers KV with Persistence

cloudworker --debug --kv-file KeyValueStore=kv.json --kv-set KeyValueStore.key=value --kv-set KeyValueStore.hello=world example/example-kv.js
curl localhost:3000/

WebAssembly

Simple

cloudworker --debug --wasm Wasm=example/simple.wasm example/example-wasm-simple.js
curl localhost:3000/

WebAssembly Source

Inverse Square Root

cloudworker --debug --wasm isqrt=example/isqrt.wasm example/example-wasm-isqrt.js
curl localhost:3000/?num=9

WebAssembly Source

Resizer

cloudworker --debug --wasm RESIZER_WASM=example/resizer.wasm example/example-wasm-resizer.js
curl localhost:3000/wasm-demo/dogdrone.png?width=210 # or open in browser

WebAssembly Source

License

MIT

Current Tags

  • 0.0.2                                ...           latest (3 months ago)

2 Versions

  • 0.0.2                                ...           3 months ago
  • 0.0.1                                ...           3 months ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (9)
Dev Dependencies (12)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |