node-cloudworker
A local dev environment for cloudflare workers
Last updated 3 days ago by markusahlstrand .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install node-cloudworker 
SYNC missed versions from official npm registry.

The node-cloudworker is a cloudflare worker shim for node combined with a small webserver, enabling debugging locally. It should not be used in production.

It's most likely not as close to the production environment as https://github.com/dollarshaveclub/cloudworker, which most of the runtime has been borrowed from, but it makes debugging and testing possible.

Installing

Installing via NPM:

npm install node-cloudworker --save

Package Usage

const ncw = require('node-cloudworker');

// Some handlers may depend on the shims
ncw.applyShims();

const handler = event => {
    return new Response('hello', { status: 200 });
};

ncw.start(handler);

```

## Cloudflare API's

Cloudflare exposes some cloudflare-specific API's inside the workers. Parts of these are supported with shims.

### Cache

The cache api is borrowed from the [Cloudworker](https://github.com/dollarshaveclub/cloudworker) repo.

### KV-Storage (Beta)

The kv-storage api is using the Cloudflare rest-api to access the KV-Storage. It requires some configuration when applying the shims so that it can access the cloudflare api's:
```
ncw.applyShims({
  kv: {
    accountId: process.env.CLOUDFLARE_ACCOUNT_ID,
    authEmail: process.env.CLOUDFLARE_AUTH_EMAIL,
    authKey: process.env.CLOUDFLARE_AUTH_KEY,
    bindings: [
      {
        variable: 'TEST',
        namespace: process.env.KV_STORAGE_NAMESPACE,
      },
    ],
  },
});
```

So far it only supports CRUD-operations and it does not include the metadata-functionality as this is not yet available through the rest-api.

Current Tags

  • 1.3.3                                ...           latest (3 days ago)

16 Versions

  • 1.3.3                                ...           3 days ago
  • 1.3.2                                ...           a month ago
  • 1.3.1                                ...           a month ago
  • 1.3.0                                ...           a month ago
  • 1.2.0                                ...           2 months ago
  • 1.1.3                                ...           9 months ago
  • 1.1.2                                ...           a year ago
  • 1.1.1                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.6                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 24
Last Day 0
Last Week 24
Last Month 21
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |