0.7.1 • Published 7 months ago

cf-bindings-proxy v0.7.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago


This library was written to accompany @cloudflare/next-on-pages, so that you can use bindings when developing Next.js apps locally through next dev.

It is intended to be used for frameworks that do not support Cloudflare bindings in a fast HMR environment.

Usage

import { binding } from 'cf-bindings-proxy';

const value = await binding<KVNamespace>('MY_KV').get('key');

How It Works

Starting the proxy spawns an instance of Wrangler using a template, passing through any commands and bindings that are supplied to the CLI. It uses port 8799.

In development mode, when interacting with a binding through the binding('BINDING_NAME') function, it sends HTTP requests to the proxy. These HTTP requests contain destructured function calls, which are then reconstructed and executed inside the proxy. The result is then returned to the client.

When building for production, binding('BINDING_NAME') simply calls process.env.BINDING_NAME to retrieve the binding instead.

When It's Active

Calls to binding('BINDING_NAME') will try to use the proxy when either of the following two conditions are met:

  • The ENABLE_BINDINGS_PROXY environment variable is set to true. OR
  • The DISABLE_BINDINGS_PROXY environment variable is not set and NODE_ENV is set to development.

Supported

Note: Functionality and bindings not listed below may still work but have not been tested.

KV

  • put
  • get
  • list
  • getWithMetadata
  • delete

D1

  • prepare
    • bind
    • run
    • all
    • first
    • raw
  • batch
  • exec
  • dump

R2

  • put
    • writeHttpMetadata
  • get
    • writeHttpMetadata
    • text
    • json
    • arrayBuffer
    • blob
    • body
    • bodyUsed
  • head
    • writeHttpMetadata
  • list
    • writeHttpMetadata
  • delete
  • createMultipartUpload
  • resumeMultipartUpload
0.2.8-918bb55

9 months ago

0.4.1-7b0d1ae

9 months ago

0.3.2-8527c95

9 months ago

0.6.0-dc52fd6

8 months ago

0.3.1-fc01172

9 months ago

0.4.1-d87efba

9 months ago

0.2.6-cba5669

10 months ago

0.3.1-3c3f882

9 months ago

0.2.4-c8c7bb6

10 months ago

0.3.3-68da632

9 months ago

0.2.3-a19f372

10 months ago

0.2.6-cee0cf1

9 months ago

0.4.0-c330ca5

9 months ago

0.5.0-906b21f

8 months ago

0.2.4-c55671b

10 months ago

0.3.0

9 months ago

0.7.1

7 months ago

0.4.0-ab73898

9 months ago

0.5.0

9 months ago

0.3.2

9 months ago

0.3.1

9 months ago

0.7.0

8 months ago

0.3.3

9 months ago

0.2.6-84b0638

9 months ago

0.4.1-f91308e

9 months ago

0.2.8-18a25d1

9 months ago

0.7.0-963e083

8 months ago

0.2.7-705a99e

9 months ago

0.2.3-000367c

10 months ago

0.2.2-ab8484a

10 months ago

0.5.0-50ff06b

9 months ago

0.2.7-0847c91

9 months ago

0.7.1-471e9fe

7 months ago

0.2.5-a62079e

10 months ago

0.3.2-0b7bfb2

9 months ago

0.3.0-803dd41

9 months ago

0.7.0-d2cc335

7 months ago

0.3.3-61d928a

9 months ago

0.2.7

9 months ago

0.2.6

10 months ago

0.2.8

9 months ago

0.4.1

9 months ago

0.2.3

10 months ago

0.4.0

9 months ago

0.3.0-2725345

9 months ago

0.2.5

10 months ago

0.6.0

8 months ago

0.2.5-38c1ac9

10 months ago

0.2.4

10 months ago

0.2.2-406efa5

11 months ago

0.2.2

11 months ago

0.2.1-5289f47

11 months ago

0.2.1-54bbefd

11 months ago

0.2.1

11 months ago

0.2.0-0c387c0

11 months ago

0.2.0-ef3e906

11 months ago

0.2.0

11 months ago

0.1.0-0f37886

11 months ago