New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cf-bindings-proxy

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cf-bindings-proxy - npm Package Compare versions

Comparing version 0.2.8-18a25d1 to 0.2.8-918bb55

13

index.d.ts

@@ -9,6 +9,17 @@ /**

*
* @example
* By default, `process.env` is used in production, however, a custom fallback can be provided.
* ```ts
* const MY_KV = binding<KVNamespace>('MY_KV', { fallback: platform.env });
* ```
*
* @param id Binding ID.
* @param opts Binding options, such as a custom fallback.
* @returns Binding value.
*/
export declare const binding: <T>(id: string) => T;
export declare const binding: <T>(id: string, opts?: BindingOpts) => T;
type BindingOpts = {
fallback: Record<string, unknown>;
};
export {};
//# sourceMappingURL=index.d.ts.map

19

index.js

@@ -1,12 +0,15 @@

import { createBindingProxy as n } from "./proxy.js";
import { createBindingProxy as _ } from "./proxy.js";
import "./transform.js";
const p = (e) => process.env.ENABLE_BINDINGS_PROXY || !process.env.DISABLE_BINDINGS_PROXY && process.env.NODE_ENV === "development" ? new Proxy(
{},
{
get: (o, r) => n(e)[r]
}
) : process.env[e];
const B = (r, e) => {
var n, o, c, N;
return (n = process == null ? void 0 : process.env) != null && n.ENABLE_BINDINGS_PROXY || !((o = process == null ? void 0 : process.env) != null && o.DISABLE_BINDINGS_PROXY) && ((c = process == null ? void 0 : process.env) == null ? void 0 : c.NODE_ENV) === "development" ? new Proxy(
{},
{
get: (s, i) => _(r)[i]
}
) : (N = (e == null ? void 0 : e.fallback) ?? (process == null ? void 0 : process.env)) == null ? void 0 : N[r];
};
export {
p as binding
B as binding
};
//# sourceMappingURL=index.js.map
{
"name": "cf-bindings-proxy",
"version": "0.2.8-18a25d1",
"version": "0.2.8-918bb55",
"description": "Experimental proxy for interfacing with bindings in projects targeting Cloudflare Pages",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -48,2 +48,10 @@ <p align="center">

It is also possible to specify a custom fallback for use in production instead of `process.env`.
```ts
import { binding } from 'cf-bindings-proxy';
const value = await binding<KVNamespace>('MY_KV', { fallback: platform.env }).get('key');
```
## How It Works

@@ -55,3 +63,3 @@

When building for production, `binding('BINDING_NAME')` simply calls `process.env.BINDING_NAME` to retrieve the binding instead.
When building for production, `binding('BINDING_NAME')` simply calls `process.env.BINDING_NAME` to retrieve the binding instead. If you wish to use a custom fallback like `platform.env` instead of `process.env`, you can pass a custom fallback to the binding call with `binding('BINDING_NAME', { fallback: platform.env })`.

@@ -58,0 +66,0 @@ ### When It's Active

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc