New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

cf-workers-proxy

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cf-workers-proxy

Enable Cloudflare Workers runtime for local development. Compatible with DrizzleORM

latest
Source
npmnpm
Version
0.6.3
Version published
Maintainers
1
Created
Source

cf-workers-proxy

Download Version

Enable Cloudflare Workers runtime for local development. Compatible with DrizzleORM.

Get Started

Install wrangler

npm i -D wrangler

Install cf-workers-proxy

npm i -D cf-workers-proxy

Example wrangler.toml

name = "worker"
compatibility_date = "2023-07-02"

[[d1_databases]]
binding = "D1"
database_name = "D1"
database_id = "<d1-id>"

[[kv_namespaces]]
binding = "KV"
id = "<kv-id>"
preview_id = "<same-kv-id-as-above>"

[[services]]
binding = "WORKER"
service = "<worker-name>"
environment = "production"

Start proxy

npx wrangler node_modules/cf-workers-proxy/dist/worker.js --remote

Example SvelteKit project

// file: app.d.ts

declare global {
  namespace App {
    interface Locals {
      D1: D1Database;
    }
    interface Platform {
      env?: {
        D1: D1Database;
      };
    }
  }
}

export {};
// file: src/hooks.server.ts

import { createD1 } from 'cf-workers-proxy';

export const handle = ({ event, resolve }) => {
  event.locals.D1 = event.platform?.env?.D1 ?? createD1('D1');
  // or createD1('D1', { hostname: 'custom-host-name' });
  // default hostname is `http://127.0.0.1:8787`
  return resolve(event);
};

Roadmap

  • ❌ Not started
  • 🟡 Partially implemented
  • ✅ Complete

D1Database

import { createD1 } from 'cf-workers-proxy';
FunctionStatus
prepare()
batch()
dump()
exec()

D1PreparedStatement

FunctionStatus
first()
run()
all()
raw()
bind()

Service Bindings

import { createServiceBinding } from 'cf-workers-proxy';
FunctionStatus
fetch()
connect()

KVNamespace

import { createKV } from 'cf-workers-proxy';
FunctionStatus
put()🟡
get()🟡
getWithMetadata()
delete()
list()

waitUntil

// file: app.d.ts
namespace App {
  interface Platform {
    context: {
      waitUntil(promise: Promise<any>): void;
    };
  }
}
// file: +page.server.ts
import { waitUntil } from 'cf-workers-proxy';

export const actions = {
  default: ({ locals, platform }) => {
    waitUntil(async () => {}, platform?.context.waitUntil);
    return { message: 'success' };
  },
};

Contributing

Buy Me A Coffee

or pull request 😐

Keywords

cloudflare

FAQs

Package last updated on 21 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts