Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/node-libraries/cloudflare-exec
Running Scripts on Cloudflare
https://github.com/node-libraries/cloudflare-exec
Last synced: about 2 months ago
JSON representation
Running Scripts on Cloudflare
- Host: GitHub
- URL: https://github.com/node-libraries/cloudflare-exec
- Owner: node-libraries
- License: mit
- Created: 2024-03-23T09:10:15.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-07-14T13:12:25.000Z (6 months ago)
- Last Synced: 2024-11-11T23:38:46.199Z (about 2 months ago)
- Language: JavaScript
- Size: 115 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cloudflare-exec
Running Scripts on Cloudflare Workers
## usage
```text
USAGE
command [options]
ARGUMENTS
Path to the script file
OPTIONS
-r, --remote Run remotely(Default is local)
-c, --config Path to the wrangler config file(Default is wrangler.toml)
-e, --env Environment
-l, --log "log" | "none" | "info" | "error" | "warn" | "debug"
```## example
- wrangler.toml
```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
```ts
import { PrismaD1 } from '@prisma/adapter-d1';
import { PrismaClient } from '@prisma/client';
import { WorkersFunction } from 'cloudflare-exec';type Env = {
DB: D1Database;
};const main: WorkersFunction = async ({ env }) => {
const adapter = new PrismaD1(env.DB);
const prisma = new PrismaClient({ adapter });// seed data
};export default main;
```### local execution
```sh
cloudflare-exec --e local prisma/seed
```### remote execution
```sh
cloudflare-exec -r prisma/seed
```