Skip to content

Out-of-the-box, edge runtime compatible services for scalable, modern architectures.

License

Notifications You must be signed in to change notification settings

cloudmix-dev/workertown

Repository files navigation

Workertown

Sensible defaults, advanced configuration.

Workertown is a collection of packages for building edge-runtime architectures.

You can check out the docs here.

Packages

TL;DR

Create a production-ready feature flag service on the edge

npx wrangler init feature-flags && cd ./feature-flags
npm i @workertown/feature-flags
// src/worker.ts
import { featureFlags } from "@workertown/feature-flags";

export default featureFlags();
// wrangler.toml
name = "feature-flags"
main = "src/worker.ts"
compatibility_date = "2023-05-30"

workers_dev = false
route = { pattern = "flags.example.com/*", zone_name = "example.com" }

[vars]
FLAGS_API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

[[kv_namespaces]]
binding = "FLAGS_CACHE"
id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
preview_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

[[d1_databases]]
binding = "FLAGS_DB"
database_name = "feature-flags"
database_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
preview_database_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
npx wrangler publish

Create a production-ready file service on the edge

npx wrangler init files && cd ./files
npm i @workertown/files
// src/worker.ts
import { files } from "@workertown/files";

export default files();
// wrangler.toml
name = "files"
main = "src/worker.ts"
compatibility_date = "2023-05-30"

workers_dev = false
route = { pattern = "files.example.com/*", zone_name = "example.com" }

[vars]
FILES_API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

[[d1_databases]]
binding = "FILES_DB"
database_name = "files"
database_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
preview_database_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

[[r2_buckets]]
binding = "FILES_FILES"
bucket_name = "files"
preview_bucket_name = "files"

Create a production-ready key/value service on the edge

npx wrangler init kv && cd ./kv
npm i @workertown/kv
// src/worker.ts
import { kv } from "@workertown/kv";

export default kv();
// wrangler.toml
name = "kv"
main = "src/worker.ts"
compatibility_date = "2023-05-30"

workers_dev = false
route = { pattern = "kv.example.com/*", zone_name = "example.com" }

[vars]
KV_API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

[[kv_namespaces]]
binding = "KV_DB"
id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
preview_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
npx wrangler publish

Create a production-ready HTTP pub/sub service on the edge

npx wrangler init pub-sub && cd ./pub-sub
npm i @workertown/pub-sub
// src/worker.ts
import { pubSub } from "@workertown/pub-sub";

export default pubSub();
// wrangler.toml
name = "pub-sub"
main = "src/worker.ts"
compatibility_date = "2023-05-30"

workers_dev = false
route = { pattern = "pubsub.example.com/*", zone_name = "example.com" }

[vars]
PUBSUB_API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

[[d1_databases]]
binding = "PUBSUB_DB"
database_name = "pub-sub"
database_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
preview_database_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

[[queues.producers]]
queue = "pub-sub"
binding = "PUBSUB_QUEUE"

[[queues.consumers]]
queue = "pub-sub"
max_batch_size = 100
max_batch_timeout = 30
max_concurrency = 10
npx wrangler publish

Create a production-ready text search service on the edge

npx wrangler init search && cd ./search
npm i @workertown/search
// src/worker.ts
import { search } from "@workertown/search";

export default search();
// wrangler.toml
name = "search"
main = "src/worker.ts"
compatibility_date = "2023-05-30"

workers_dev = false
route = { pattern = "search.example.com/*", zone_name = "example.com" }

[vars]
SEARCH_API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

[[kv_namespaces]]
binding = "SEARCH_CACHE"
id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
preview_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

[[d1_databases]]
binding = "SEARCH_DB"
database_name = "search"
database_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
preview_database_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
npx wrangler publish

About

Out-of-the-box, edge runtime compatible services for scalable, modern architectures.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published