All Projects → cloudflare → Serverless Cloudflare Workers

cloudflare / Serverless Cloudflare Workers

Licence: bsd-3-clause
Serverless provider plugin for Cloudflare Workers

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Serverless Cloudflare Workers

Google Drive Index
Index Google Drive Files Easily and Free
Stars: ✭ 205 (+79.82%)
Mutual labels:  workers, cloudflare
cloudflare-worker-router
A super lightweight router (1.3K) with middleware support and ZERO dependencies for CloudFlare Workers.
Stars: ✭ 144 (+26.32%)
Mutual labels:  workers, cloudflare
Cfworker
A collection of packages optimized for Cloudflare Workers and service workers.
Stars: ✭ 152 (+33.33%)
Mutual labels:  workers, cloudflare
Worker Typescript Template
ʕ •́؈•̀) TypeScript template for Cloudflare Workers
Stars: ✭ 129 (+13.16%)
Mutual labels:  workers, cloudflare
natural
Fastest Framework for NodeJS. Written in pure ES6+
Stars: ✭ 30 (-73.68%)
Mutual labels:  workers, cloudflare
viteflare
Cloudflare workers meet Vite plugins
Stars: ✭ 35 (-69.3%)
Mutual labels:  workers, cloudflare
worker-template-postgres
Reference demo and modified PostgreSQL driver to connect Cloudflare Workers to a relational database.
Stars: ✭ 75 (-34.21%)
Mutual labels:  workers, cloudflare
cloudflare-worker-graphql-ws-template
A template for WebSockets powered Cloudflare Worker project using graphql-ws
Stars: ✭ 21 (-81.58%)
Mutual labels:  workers, cloudflare
vite-plugin-cloudflare
🔥Building Cloudflare workers is faster and easier using vite-plugin-cloudflare with node builtins like process and stream
Stars: ✭ 108 (-5.26%)
Mutual labels:  workers, cloudflare
workers-jwt
Generate JWTs on Cloudflare Workers using the WebCrypto API
Stars: ✭ 67 (-41.23%)
Mutual labels:  workers, cloudflare
cloudflare-worker-rest-api
A cloudflare worker module which helps building REST Api quickly and easily, similar to express framework.
Stars: ✭ 31 (-72.81%)
Mutual labels:  workers, cloudflare
Create Google Shared Drive
Cloudflare Redesigned Script for creating a Shared/Team Drive
Stars: ✭ 93 (-18.42%)
Mutual labels:  workers, cloudflare
Openaudiomc
A real time web client for minecraft to play and manage sounds, game notifications and much more. This project includes the plugin (bungee + spigot + velocity), common java library, web client and build scripts.
Stars: ✭ 89 (-21.93%)
Mutual labels:  cloudflare
Cfrpki
Cloudflare's RPKI Toolbox
Stars: ✭ 104 (-8.77%)
Mutual labels:  cloudflare
Upper
Integrates Edge Caches like Fastly, KeyCDN, Cloudflare and Varnish with Craft.
Stars: ✭ 89 (-21.93%)
Mutual labels:  cloudflare
Airtable Proxy Worker
A Cloudflare Worker that allows you to make secure requests to the Airtable API from your frontend.
Stars: ✭ 87 (-23.68%)
Mutual labels:  cloudflare
Workers
Cloudflare Workers
Stars: ✭ 111 (-2.63%)
Mutual labels:  workers
Cloudflare Warp Wireguard Client
Generate WireGuard profile from Cloudflare Warp account
Stars: ✭ 102 (-10.53%)
Mutual labels:  cloudflare
Flow Pipeline
A set of tools and examples to run a flow-pipeline (sFlow, NetFlow)
Stars: ✭ 86 (-24.56%)
Mutual labels:  cloudflare
Ngx Papaparse
Papa Parse wrapper for Angular
Stars: ✭ 83 (-27.19%)
Mutual labels:  workers

serverless-cloudflare-workers

Serverless plugin for Cloudflare Workers

Documentation

https://serverless.com/framework/docs/providers/cloudflare/guide/quick-start/

Bundling with Webpack

You can have the plugin automatically bundle your code into one file using webpack. This is a great solution if you are fine with a no frills bundling.

You can use a single global webpack config to bundle your assets. And this webpack config will be built during the packaging time, before individual functions are prepared. To use this, add webpackConfig to your service section in serverless config, with value as the path to the webpack config.

service:
  name: service-name
  webpackConfig: webpack.config #webpack config path without js extension from root folder.
  config:
    accountId: ${env:CLOUDFLARE_ACCOUNT_ID}
    zoneId: ${env:CLOUDFLARE_ZONE_ID}

You can also add a function level webpack configuration in addition to a global webpack configuration. This helps you to process bundling different for an individual function than the global webpack config explained earlier. To use this, set the webpack config path to the function level webpack variable. Setting function level webpack variable to true will force webpack to bundle the function script with a default web pack configuration. Setting webpack key to false will turn off webpack for the function. (i.e the function script will not be fetched from dist folder)

Simply add webpack: true | <config path> to your config block.

functions:
  myfunction:
    name: myfunction
    webpack: true #or the web pack config path for this function
    script: handlers/myfunctionhandler
    events:
      - http:
          url: example.com/myfunction
          method: GET
  

Environment Variables

While Cloudflare Workers doesn't exactly offer environment vairables, we can bind global variables to values, essentially giving the same capabilities. In your function configuration, add key value pairs in environment

functions:
  myFunction:
    environment:
      MYKEY: value_of_my_key
      ANOTHER_KEY_OF_MINE: sweet_child_o_mine

Then in your script, you can reference MYKEY to access the value.

You can also add an environment block under provider. These will get added to every function. If a function defines the same variable, the function defintion will overwrite the provider block definition.

provider:
  name: cloudflare
  environment:
    MYKEY: value_of_my_key
    ANOTHER_KEY_OF_MINE: sweet_child_o_mine

Using Cloudflare KV Storage

The plugin can create and bind a KV Storage namespace for your function by simpling adding a resources section.

The following will create a namespace called BEST_NAMESPACE and bind the variable TEST to that namespace inside myfunction.

functions:
  myfunction:
    name: myfunction
    webpack: true
    script: handlers/myfunctionhandler
    resources:
      kv:
        - variable: TEST
          namespace: BEST_NAMESPACE
    events:
      - http:
          url: example.com/myfunction
          method: GET

Web Assembly

The plugin can upload and bind WASM to execute in your worker. The easiest way to do this is to use the --template cloudflare-workers-rust when generating a project. The template includes a Rust create folder setup with wasm-pack, a webpack script for adding the generated javascript into your project, and the yml file settings to upload the wasm file itself.

functions:
  myfunction:
    name: myfunction
    webpack: true
    script: handlers/myfunctionhandler
    resources:
      wasm:
        - variable: WASM
          filename: rust/pkg/wasm_bg.wasm
    events:
      - http:
          url: example.com/myfunction
          method: GET
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].