Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
create-cloudflare-worker
Advanced tools
A Starter Kit for Building a Cloudflare Worker
To create a new worker with create-cloudflare-worker
, run the following
npm init cloudflare-worker your-worker-name
or, with npx
npx create-cloudflare-worker your-worker-name
Once the installation is done, you can open your project folder:
cd my-app
To build the worker, run
npm run build
This outputs the worker as dist/main.js
.
To continually build the worker on every change, run
npm run watch
And finally, to execute the integration and unit tests, run
npm test
To run the worker locally, run
npm start
This will start the worker on port 4000, and forward all requests to the upstream server at http://localhost:3000
. This will allow you to develop your application in tandem with the worker that will front the application.
This project may be used to deploy your newly built worker to cloudflare as follows:
CF_ACCOUNT=acct-id CF_WORKER_NAME=worker-name CF_EMAIL=you@you.com CF_AUTH_KEY=auth-key npm run deploy
However, you may also just copy dist/main.js and paste it into the CF worker dashboard (or even terraform it)
We will add recipes here
This project can also mock an in memory KV Store. This can be done as follows
KV_NAMESPACES
as follows KV_NAMESPACES=MYSTORE,OTHER_STORE npm start
const app = createTestApp(workerContents, upstreamApp, { kvStores: ["MYSTORE"] })
. The new store can be accessed in tests as follows: await app.stores.MYSTORE.put("key", "value")
. await app.stores.MYSTORE.get("key")
When you are ready to deploy your new worker with a KV:
# If this fails, contact support
curl "https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT/workers/namespaces" \
-X POST \
-H "X-Auth-Email: $CF_EMAIL" \
-H "X-Auth-Key: $AUTH_KEY" \
-H "Content-Type: application/json" \
--data '{"title": "your-namespace"}'
# {"result":{"id": "<some-id>","title":"your-namespace"}}
\\\"bindings\\\":[{\\\"name\\\":\\\"MYSTORE\\\",\\\"type\\\":\\\"kv_namespace\\\",\\\"namespace_id\\\":\\\"$MYSTORE_ID\\\"}]
$ npm install
This work is licensed under the ISC license.
1.1.3 (2019-01-04)
<a name="1.1.2"></a>
FAQs
Create a Cloudflare worker
The npm package create-cloudflare-worker receives a total of 7 weekly downloads. As such, create-cloudflare-worker popularity was classified as not popular.
We found that create-cloudflare-worker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.