Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-cloudflare-worker

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-cloudflare-worker

Create a Cloudflare worker

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-41.67%
Maintainers
1
Weekly downloads
 
Created
Source

create-cloudflare-worker create-cloudflare-worker

A Starter Kit for Building a Cloudflare Worker

Creating an App

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

Building and testing your new worker

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

Running the worker locally

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.

Deploying

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)

Examples

We will add recipes here

  • Building a API service with react-router
  • Parsing Cookies

Adding a Key Value Store

FIXME: How to add a KeyValue namespace

  • Curl to create the KV Namespace
  • Update the deploy step in package.json to bind the KV namespace
  • Create a test KV namespace in code.

Contributing

  • Fork this Repo first
  • Clone your Repo
  • Install dependencies by $ npm install
  • Checkout a feature branch
  • Feel free to add your features
  • Make sure your features are fully tested
  • Publish your local branch, Open a pull request
  • Enjoy hacking <3

ISC

This work is licensed under the ISC license.


Keywords

FAQs

Package last updated on 02 Jan 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc