Add cloudflare worker config
This commit is contained in:
parent
aeb6dcea37
commit
f8412939c7
5 changed files with 816 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -20,3 +20,4 @@ dist-ssr
|
||||||
*.suo
|
*.suo
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
|
.wrangler/*
|
||||||
|
|
|
@ -8,9 +8,13 @@
|
||||||
"build": "farm build",
|
"build": "farm build",
|
||||||
"preview": "farm preview",
|
"preview": "farm preview",
|
||||||
"clean": "farm clean",
|
"clean": "farm clean",
|
||||||
"check": "svelte-check --tsconfig ./tsconfig.json"
|
"check": "svelte-check --tsconfig ./tsconfig.json",
|
||||||
|
"deploy": "wrangler deploy",
|
||||||
|
"wrangler-dev": "wrangler dev",
|
||||||
|
"wrangler-start": "wrangler dev"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@cloudflare/kv-asset-handler": "^0.3.4",
|
||||||
"@farmfe/cli": "^1.0.2",
|
"@farmfe/cli": "^1.0.2",
|
||||||
"@farmfe/core": "^1.3.0",
|
"@farmfe/core": "^1.3.0",
|
||||||
"@sveltejs/vite-plugin-svelte": "^3.0.2",
|
"@sveltejs/vite-plugin-svelte": "^3.0.2",
|
||||||
|
@ -19,6 +23,7 @@
|
||||||
"svelte": "^4.2.12",
|
"svelte": "^4.2.12",
|
||||||
"svelte-check": "^3.6.8",
|
"svelte-check": "^3.6.8",
|
||||||
"tslib": "^2.6.2",
|
"tslib": "^2.6.2",
|
||||||
"typescript": "^5.4.3"
|
"typescript": "^5.4.3",
|
||||||
|
"wrangler": "^3.67.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
675
pnpm-lock.yaml
675
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
19
src/cloudflare.js
Normal file
19
src/cloudflare.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import { getAssetFromKV } from "@cloudflare/kv-asset-handler";
|
||||||
|
|
||||||
|
addEventListener("fetch", (event) => {
|
||||||
|
event.respondWith(handleEvent(event));
|
||||||
|
});
|
||||||
|
|
||||||
|
async function handleEvent(event) {
|
||||||
|
try {
|
||||||
|
// Add logic to decide whether to serve an asset or run your original Worker code
|
||||||
|
return await getAssetFromKV(event);
|
||||||
|
} catch (e) {
|
||||||
|
let pathname = new URL(event.request.url).pathname;
|
||||||
|
return new Response(`"${pathname}" not found`, {
|
||||||
|
status: 404,
|
||||||
|
statusText: "not found",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
113
wrangler.toml
Normal file
113
wrangler.toml
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
#:schema node_modules/wrangler/config-schema.json
|
||||||
|
name = "vdo-ninja-multistream"
|
||||||
|
main = "src/cloudflare.js"
|
||||||
|
compatibility_date = "2024-07-25"
|
||||||
|
compatibility_flags = ["nodejs_compat"]
|
||||||
|
route = "https://vdo.doggoat.de/*"
|
||||||
|
send_metrics = false
|
||||||
|
|
||||||
|
# Automatically place your workloads in an optimal location to minimize latency.
|
||||||
|
# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
|
||||||
|
# rather than the end user may result in better performance.
|
||||||
|
# Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
|
||||||
|
# [placement]
|
||||||
|
# mode = "smart"
|
||||||
|
|
||||||
|
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
||||||
|
# Docs:
|
||||||
|
# - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
||||||
|
# Note: Use secrets to store sensitive data.
|
||||||
|
# - https://developers.cloudflare.com/workers/configuration/secrets/
|
||||||
|
# [vars]
|
||||||
|
# MY_VARIABLE = "production_value"
|
||||||
|
|
||||||
|
# Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
|
||||||
|
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
|
||||||
|
# [ai]
|
||||||
|
# binding = "AI"
|
||||||
|
|
||||||
|
# Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function.
|
||||||
|
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
|
||||||
|
# [[analytics_engine_datasets]]
|
||||||
|
# binding = "MY_DATASET"
|
||||||
|
|
||||||
|
# Bind a headless browser instance running on Cloudflare's global network.
|
||||||
|
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
|
||||||
|
# [browser]
|
||||||
|
# binding = "MY_BROWSER"
|
||||||
|
|
||||||
|
# Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
|
||||||
|
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
|
||||||
|
# [[d1_databases]]
|
||||||
|
# binding = "MY_DB"
|
||||||
|
# database_name = "my-database"
|
||||||
|
# database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
|
||||||
|
# Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.
|
||||||
|
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
|
||||||
|
# [[dispatch_namespaces]]
|
||||||
|
# binding = "MY_DISPATCHER"
|
||||||
|
# namespace = "my-namespace"
|
||||||
|
|
||||||
|
# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
|
||||||
|
# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
|
||||||
|
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
||||||
|
# [[durable_objects.bindings]]
|
||||||
|
# name = "MY_DURABLE_OBJECT"
|
||||||
|
# class_name = "MyDurableObject"
|
||||||
|
|
||||||
|
# Durable Object migrations.
|
||||||
|
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations
|
||||||
|
# [[migrations]]
|
||||||
|
# tag = "v1"
|
||||||
|
# new_classes = ["MyDurableObject"]
|
||||||
|
|
||||||
|
# Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers.
|
||||||
|
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
|
||||||
|
# [[hyperdrive]]
|
||||||
|
# binding = "MY_HYPERDRIVE"
|
||||||
|
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||||
|
|
||||||
|
# Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
|
||||||
|
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
|
||||||
|
# [[kv_namespaces]]
|
||||||
|
# binding = "MY_KV_NAMESPACE"
|
||||||
|
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||||
|
|
||||||
|
# Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
|
||||||
|
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
|
||||||
|
# [[mtls_certificates]]
|
||||||
|
# binding = "MY_CERTIFICATE"
|
||||||
|
# certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
|
||||||
|
# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
|
||||||
|
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
||||||
|
# [[queues.producers]]
|
||||||
|
# binding = "MY_QUEUE"
|
||||||
|
# queue = "my-queue"
|
||||||
|
|
||||||
|
# Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
|
||||||
|
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
||||||
|
# [[queues.consumers]]
|
||||||
|
# queue = "my-queue"
|
||||||
|
|
||||||
|
# Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
|
||||||
|
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
|
||||||
|
# [[r2_buckets]]
|
||||||
|
# binding = "MY_BUCKET"
|
||||||
|
# bucket_name = "my-bucket"
|
||||||
|
|
||||||
|
# Bind another Worker service. Use this binding to call another Worker without network overhead.
|
||||||
|
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
||||||
|
# [[services]]
|
||||||
|
# binding = "MY_SERVICE"
|
||||||
|
# service = "my-service"
|
||||||
|
|
||||||
|
# Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases.
|
||||||
|
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
|
||||||
|
# [[vectorize]]
|
||||||
|
# binding = "MY_INDEX"
|
||||||
|
# index_name = "my-index"
|
||||||
|
|
||||||
|
[site]
|
||||||
|
bucket = './dist'
|
Loading…
Reference in a new issue