Socket
Book a DemoInstallSign in
Socket

cloudflare-exec

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudflare-exec

Running Scripts on Cloudflare Workers

latest
Source
npmnpm
Version
0.0.7
Version published
Maintainers
1
Created
Source

cloudflare-exec

Running Scripts on Cloudflare Workers

usage

USAGE
        command [options] <path>
ARGUMENTS
        <path> Path to the script file
OPTIONS
        -r, --remote Run remotely(Default is local)
        -c, --config <path> Path to the wrangler config file(Default is wrangler.toml)
        -e, --env <environment> Environment
        -l, --log <logLevel> "log" | "none" | "info" | "error" | "warn" | "debug"

example

  • wrangler.toml
name = "xxxx"
main = "src/index.ts"
compatibility_date = "2024-03-14"
node_compat = true
minify = true

[[d1_databases]]
binding = "DB"
database_name = "test-db"
database_id ="xxxxxx"

[env.local]
d1_databases=[
  {binding = "DB",database_name = "test-db",database_id ="test-db"}
]

  • prisma/seed.ts
import { PrismaD1 } from '@prisma/adapter-d1';
import { PrismaClient } from '@prisma/client';
import { WorkersFunction } from 'cloudflare-exec';

type Env = {
  DB: D1Database;
};

const main: WorkersFunction<Env> = async ({ env }) => {
  const adapter = new PrismaD1(env.DB);
  const prisma = new PrismaClient({ adapter });

  // seed data
};

export default main;

local execution

cloudflare-exec --e local prisma/seed

remote execution

cloudflare-exec -r prisma/seed

FAQs

Package last updated on 14 Jul 2024

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