From ab81dd60c237aded6571874a981c2077b800fc1f Mon Sep 17 00:00:00 2001 From: Nirvik Ghosh Date: Thu, 23 Aug 2018 16:18:05 -0500 Subject: [PATCH 01/18] whitelisted cloudflare templates --- lib/plugins/create/create.js | 2 ++ .../cloudflare-workers-enterprise/.gitignore | 3 ++ .../cloudflare-workers-enterprise/bar.js | 7 ++++ .../helloWorld.js | 7 ++++ .../package.json | 14 ++++++++ .../serverless.yml | 35 +++++++++++++++++++ .../templates/cloudflare-workers/.gitignore | 3 ++ .../cloudflare-workers/helloWorld.js | 7 ++++ .../templates/cloudflare-workers/package.json | 14 ++++++++ .../cloudflare-workers/serverless.yml | 24 +++++++++++++ 10 files changed, 116 insertions(+) create mode 100644 lib/plugins/create/templates/cloudflare-workers-enterprise/.gitignore create mode 100644 lib/plugins/create/templates/cloudflare-workers-enterprise/bar.js create mode 100644 lib/plugins/create/templates/cloudflare-workers-enterprise/helloWorld.js create mode 100644 lib/plugins/create/templates/cloudflare-workers-enterprise/package.json create mode 100644 lib/plugins/create/templates/cloudflare-workers-enterprise/serverless.yml create mode 100644 lib/plugins/create/templates/cloudflare-workers/.gitignore create mode 100644 lib/plugins/create/templates/cloudflare-workers/helloWorld.js create mode 100644 lib/plugins/create/templates/cloudflare-workers/package.json create mode 100644 lib/plugins/create/templates/cloudflare-workers/serverless.yml diff --git a/lib/plugins/create/create.js b/lib/plugins/create/create.js index 259d6b4bcb6..0a14601f1d3 100644 --- a/lib/plugins/create/create.js +++ b/lib/plugins/create/create.js @@ -33,6 +33,8 @@ const validTemplates = [ 'aws-go', 'aws-go-dep', 'azure-nodejs', + 'cloudflare-workers', + 'cloudflare-workers-enterprise', 'fn-nodejs', 'fn-go', 'google-nodejs', diff --git a/lib/plugins/create/templates/cloudflare-workers-enterprise/.gitignore b/lib/plugins/create/templates/cloudflare-workers-enterprise/.gitignore new file mode 100644 index 00000000000..9e5bccff87d --- /dev/null +++ b/lib/plugins/create/templates/cloudflare-workers-enterprise/.gitignore @@ -0,0 +1,3 @@ +# Serverless directories +.serverless +node_modules/ diff --git a/lib/plugins/create/templates/cloudflare-workers-enterprise/bar.js b/lib/plugins/create/templates/cloudflare-workers-enterprise/bar.js new file mode 100644 index 00000000000..14359baeab9 --- /dev/null +++ b/lib/plugins/create/templates/cloudflare-workers-enterprise/bar.js @@ -0,0 +1,7 @@ +addEventListener('fetch', event => { + event.respondWith(handleRequest(event.request)) + }) + + async function handleRequest(request) { + return new Response("Foo is not Bar") + } diff --git a/lib/plugins/create/templates/cloudflare-workers-enterprise/helloWorld.js b/lib/plugins/create/templates/cloudflare-workers-enterprise/helloWorld.js new file mode 100644 index 00000000000..dbede8a6255 --- /dev/null +++ b/lib/plugins/create/templates/cloudflare-workers-enterprise/helloWorld.js @@ -0,0 +1,7 @@ +addEventListener('fetch', event => { + event.respondWith(handleRequest(event.request)) + }) + + async function handleRequest(request) { + return new Response("Hello world") + } diff --git a/lib/plugins/create/templates/cloudflare-workers-enterprise/package.json b/lib/plugins/create/templates/cloudflare-workers-enterprise/package.json new file mode 100644 index 00000000000..8d235eef79e --- /dev/null +++ b/lib/plugins/create/templates/cloudflare-workers-enterprise/package.json @@ -0,0 +1,14 @@ +{ + "name": "cloudflare-workers-enterprise", + "version": "1.0.0", + "description": "Cloudflare serverless deployment for enterprise customers", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "cloudflare", + "license": "MIT", + "devDependencies": { + "serverless-cloudflare-workers": "1.0.0" + } +} diff --git a/lib/plugins/create/templates/cloudflare-workers-enterprise/serverless.yml b/lib/plugins/create/templates/cloudflare-workers-enterprise/serverless.yml new file mode 100644 index 00000000000..f58ae8b2641 --- /dev/null +++ b/lib/plugins/create/templates/cloudflare-workers-enterprise/serverless.yml @@ -0,0 +1,35 @@ +service: + name: hello-world + config: + accountId: CLOUDFLARE_ACCOUNT_ID + zoneId: CLOUDFLARE_ZONE_ID + workers: + hello: + routes: + - example.com/hello/* + foo_script: + routes: + - example.com/foo/* + +provider: + name: cloudflare + +plugins: + - serverless-cloudflare-workers + +functions: + helloWorld: + worker: hello + script: helloWorld + events: + - http: + url: example.com/hello/user + method: GET + + foo: + worker: foo_script + script: bar + events: + - http: + url: example.com/foo/bar + method: GET diff --git a/lib/plugins/create/templates/cloudflare-workers/.gitignore b/lib/plugins/create/templates/cloudflare-workers/.gitignore new file mode 100644 index 00000000000..9e5bccff87d --- /dev/null +++ b/lib/plugins/create/templates/cloudflare-workers/.gitignore @@ -0,0 +1,3 @@ +# Serverless directories +.serverless +node_modules/ diff --git a/lib/plugins/create/templates/cloudflare-workers/helloWorld.js b/lib/plugins/create/templates/cloudflare-workers/helloWorld.js new file mode 100644 index 00000000000..dbede8a6255 --- /dev/null +++ b/lib/plugins/create/templates/cloudflare-workers/helloWorld.js @@ -0,0 +1,7 @@ +addEventListener('fetch', event => { + event.respondWith(handleRequest(event.request)) + }) + + async function handleRequest(request) { + return new Response("Hello world") + } diff --git a/lib/plugins/create/templates/cloudflare-workers/package.json b/lib/plugins/create/templates/cloudflare-workers/package.json new file mode 100644 index 00000000000..93082d881a7 --- /dev/null +++ b/lib/plugins/create/templates/cloudflare-workers/package.json @@ -0,0 +1,14 @@ +{ + "name": "cloudflare-workers", + "version": "1.0.0", + "description": "Cloudflare serverless deployment for self-serve customers", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "cloudflare", + "license": "MIT", + "devDependencies": { + "serverless-cloudflare-workers": "1.0.0" + } +} diff --git a/lib/plugins/create/templates/cloudflare-workers/serverless.yml b/lib/plugins/create/templates/cloudflare-workers/serverless.yml new file mode 100644 index 00000000000..d75087e169c --- /dev/null +++ b/lib/plugins/create/templates/cloudflare-workers/serverless.yml @@ -0,0 +1,24 @@ +service: + name: hello-world + config: + accountId: CLOUDFLARE_ACCOUNT_ID + zoneId: CLOUDFLARE_ZONE_ID + workers: + hello: + routes: + - example.com/hello/* + +provider: + name: cloudflare + +plugins: + - serverless-cloudflare-workers + +functions: + helloWorld: + worker: hello + script: helloWorld # there must be a file called helloWorld.js + events: + - http: + url: example.com/hello/user + method: GET From ff01f27ea7ad00b4e31f3fd9d91b95e9d8980727 Mon Sep 17 00:00:00 2001 From: Nirvik Ghosh Date: Fri, 24 Aug 2018 14:22:38 -0500 Subject: [PATCH 02/18] added headers to the self-serve template added headers in enterprise template --- .../templates/cloudflare-workers-enterprise/serverless.yml | 6 ++++++ .../create/templates/cloudflare-workers/serverless.yml | 3 +++ 2 files changed, 9 insertions(+) diff --git a/lib/plugins/create/templates/cloudflare-workers-enterprise/serverless.yml b/lib/plugins/create/templates/cloudflare-workers-enterprise/serverless.yml index f58ae8b2641..abeb14c4793 100644 --- a/lib/plugins/create/templates/cloudflare-workers-enterprise/serverless.yml +++ b/lib/plugins/create/templates/cloudflare-workers-enterprise/serverless.yml @@ -25,6 +25,9 @@ functions: - http: url: example.com/hello/user method: GET + headers: + foo: bar + x-client-data: value foo: worker: foo_script @@ -33,3 +36,6 @@ functions: - http: url: example.com/foo/bar method: GET + headers: + foo: bar + x-client-data: value diff --git a/lib/plugins/create/templates/cloudflare-workers/serverless.yml b/lib/plugins/create/templates/cloudflare-workers/serverless.yml index d75087e169c..caaaa91df0d 100644 --- a/lib/plugins/create/templates/cloudflare-workers/serverless.yml +++ b/lib/plugins/create/templates/cloudflare-workers/serverless.yml @@ -22,3 +22,6 @@ functions: - http: url: example.com/hello/user method: GET + headers: + foo: bar + x-client-data: value From d119d406057c89d215c85848a24ded9ee739b246 Mon Sep 17 00:00:00 2001 From: Stephen Pinkerton Date: Mon, 27 Aug 2018 16:29:53 -0500 Subject: [PATCH 03/18] Add cloudflare-workers documentation --- docs/providers/cloudflare-workers/README.md | 71 ++++++ .../cli-reference/README.md | 15 ++ .../cli-reference/create.md | 76 +++++++ .../cli-reference/deploy.md | 50 +++++ .../cli-reference/invoke.md | 62 ++++++ .../cli-reference/plugin-install.md | 42 ++++ .../cli-reference/plugin-list.md | 25 +++ .../cli-reference/plugin-search.md | 33 +++ .../cli-reference/plugin-uninstall.md | 33 +++ .../cli-reference/remove.md | 21 ++ .../cloudflare-workers/events/README.md | 18 ++ .../cloudflare-workers/events/http.md | 37 ++++ .../cloudflare-workers/guide/README.md | 17 ++ .../cloudflare-workers/guide/debugging.md | 62 ++++++ .../cloudflare-workers/guide/deploying.md | 113 ++++++++++ .../cloudflare-workers/guide/events.md | 39 ++++ .../cloudflare-workers/guide/functions.md | 119 +++++++++++ .../cloudflare-workers/guide/installation.md | 57 +++++ .../cloudflare-workers/guide/intro.md | 108 ++++++++++ .../cloudflare-workers/guide/quick-start.md | 105 +++++++++ .../cloudflare-workers/guide/services.md | 202 ++++++++++++++++++ .../cloudflare-workers/guide/workflow.md | 58 +++++ 22 files changed, 1363 insertions(+) create mode 100644 docs/providers/cloudflare-workers/README.md create mode 100644 docs/providers/cloudflare-workers/cli-reference/README.md create mode 100644 docs/providers/cloudflare-workers/cli-reference/create.md create mode 100644 docs/providers/cloudflare-workers/cli-reference/deploy.md create mode 100644 docs/providers/cloudflare-workers/cli-reference/invoke.md create mode 100644 docs/providers/cloudflare-workers/cli-reference/plugin-install.md create mode 100644 docs/providers/cloudflare-workers/cli-reference/plugin-list.md create mode 100644 docs/providers/cloudflare-workers/cli-reference/plugin-search.md create mode 100644 docs/providers/cloudflare-workers/cli-reference/plugin-uninstall.md create mode 100644 docs/providers/cloudflare-workers/cli-reference/remove.md create mode 100644 docs/providers/cloudflare-workers/events/README.md create mode 100644 docs/providers/cloudflare-workers/events/http.md create mode 100644 docs/providers/cloudflare-workers/guide/README.md create mode 100644 docs/providers/cloudflare-workers/guide/debugging.md create mode 100644 docs/providers/cloudflare-workers/guide/deploying.md create mode 100644 docs/providers/cloudflare-workers/guide/events.md create mode 100644 docs/providers/cloudflare-workers/guide/functions.md create mode 100644 docs/providers/cloudflare-workers/guide/installation.md create mode 100644 docs/providers/cloudflare-workers/guide/intro.md create mode 100644 docs/providers/cloudflare-workers/guide/quick-start.md create mode 100644 docs/providers/cloudflare-workers/guide/services.md create mode 100644 docs/providers/cloudflare-workers/guide/workflow.md diff --git a/docs/providers/cloudflare-workers/README.md b/docs/providers/cloudflare-workers/README.md new file mode 100644 index 00000000000..bc7bb23771b --- /dev/null +++ b/docs/providers/cloudflare-workers/README.md @@ -0,0 +1,71 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/) + + +# Cloudflare Provider Documentation + +Welcome to the Serverless Cloudflare Workers documentation! + +If you have any questions, [search the forums](https://forum.serverless.com?utm_source=framework-docs) or [start your own thread](https://forum.serverless.com?utm_source=framework-docs) + + diff --git a/docs/providers/cloudflare-workers/cli-reference/README.md b/docs/providers/cloudflare-workers/cli-reference/README.md new file mode 100644 index 00000000000..e600d5ae0db --- /dev/null +++ b/docs/providers/cloudflare-workers/cli-reference/README.md @@ -0,0 +1,15 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/cli-reference/) + + +# Serverless Cloudflare Workers CLI Reference + +Welcome to the Serverless Cloudflare Workers CLI Reference! Please select a section on the left to get started. + +If you have questions, join the [chat in gitter](https://gitter.im/serverless/serverless) or [post over on the forums](http://forum.serverless.com/). diff --git a/docs/providers/cloudflare-workers/cli-reference/create.md b/docs/providers/cloudflare-workers/cli-reference/create.md new file mode 100644 index 00000000000..51f2d12affa --- /dev/null +++ b/docs/providers/cloudflare-workers/cli-reference/create.md @@ -0,0 +1,76 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/cli-reference/create) + + + +# Cloudflare Workers - Create +Creates a new Serverless service in the current working directory based on the provided template. + +**Create service in current working directory:** + +```bash +serverless create --template cloudflare-workers +``` + +Or for Enterprise Cloudflare accounts: + +```bash +serverless create --template cloudflare-workers-enterprise +``` + +**Create service in new folder:** + +```bash +serverless create --template cloudflare-workers --path my-service +``` + +Or for Enterprise Cloudflare accounts: + +```bash +serverless create --template cloudflare-workers-enterprise --path my-service +``` + +## Options +- `--template` or `-t` The name of one of the available templates. Required if --template-url and --template-path are not present. +- `--template-url` or `-u` The name of one of the available templates. Required if --template and --template-path are not present. +- `--template-path` The local path of your template. Required if --template and --template-url are not present. +- `--path` or `-p` The path where the service should be created. +- `--name` or `-n` the name of the service in `serverless.yml`. +## Provided lifecycle events +- `create:create` +## Available Templates for Cloudflare Workers +To see a list of available templates run `serverless create --help` +These are the current available templates for Cloudflare Workers: + +- cloudflare-workers +- cloudflare-workers-enterprise + +## Examples +### Creating a new service +```bash +serverless create --template cloudflare-workers --name my-special-service +``` + +This example will generate scaffolding for a service with `Cloudflare` as a provider. The scaffolding will be generated in the current working directory. + +### Creating a named service in a (new) directory +```bash +serverless create --template cloudflare-workers --path my-new-service +``` + +This example will generate scaffolding for a service with `Cloudflare` as a provider. The scaffolding will be generated in the `my-new-service` directory. This directory will be created if not present. Otherwise, Serverless will use the already present directory. +Additionally, Serverless will rename the service according to the path you provide. In this example, the service will be renamed to `my-new-service`. + +### Creating a new service using a local template +```bash +serverless create --template-path path/to/my/template/folder --path path/to/my/service --name my-new-service +``` +This will copy the `path/to/my/template/folder` folder into `path/to/my/service` and rename the service to `my-new-service`. diff --git a/docs/providers/cloudflare-workers/cli-reference/deploy.md b/docs/providers/cloudflare-workers/cli-reference/deploy.md new file mode 100644 index 00000000000..50a8773e208 --- /dev/null +++ b/docs/providers/cloudflare-workers/cli-reference/deploy.md @@ -0,0 +1,50 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/cli-reference/deploy) + + + +# Cloudflare Workers - Deploy +In order to be able to deploy any Cloudflare Workers, You will need to set your Global API key from Cloudflare as an environmental variable named `CLOUDFLARE_AUTH_KEY`, and your Cloudflare account email as an environmental variable named `CLOUDFLARE_AUTH_EMAIL`. You can get your Global API key from your [Cloudflare profile](https://dash.cloudflare.com/profile) page. + +Environmental variables are variables that live inside your terminal. + +For Mac and Linux users, you can set environmental variables like this: + +```bash +export CLOUDFLARE_AUTH_KEY=YOUR_API_KEY_HERE +export CLOUDFLARE_AUTH_EMAIL=YOUR_CLOUDFLARE_EMAIL +``` + +And for Windows (CMD) users, you can set environmental variables like this: + +```bash +set CLOUDFLARE_AUTH_KEY=YOUR_API_KEY_HERE +set CLOUDFLARE_AUTH_EMAIL=YOUR_CLOUDFLARE_EMAIL +``` + +You’ll need to redefine your environmental variables after each time you close your terminal. + +The `serverless deploy` command deploys your entire service via the Cloudflare Workers API. Run this command when you have made service changes (i.e., you edited `serverless.yml`). +Use `serverless deploy -f my-function` when you have made code changes and you want to quickly upload your updated code to Cloudflare. + +```bash +serverless deploy +``` + +This is the simplest deployment usage possible. With this command, Serverless will deploy your service to Cloudflare. + +## Options +- `--verbose` or `-v`: Shows all stack events during deployment, and display any Stack Output. +- `--function` or `-f`: Invokes `deploy function` (see above). Convenience shortcut + +## Provided lifecycle events +- `deploy:deploy` +- `deploy:function:deploy` diff --git a/docs/providers/cloudflare-workers/cli-reference/invoke.md b/docs/providers/cloudflare-workers/cli-reference/invoke.md new file mode 100644 index 00000000000..a3bfdf030c6 --- /dev/null +++ b/docs/providers/cloudflare-workers/cli-reference/invoke.md @@ -0,0 +1,62 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/fn/cli-reference/invoke) + + +# Fn - Invoke + +Invokes deployed function. It allows to send event data to the function, read logs and display other important information of the function invocation. + +```bash +serverless invoke --function functionName +``` + +## Options +- `--function` or `-f` The name of the function in your service that you want to invoke. **Required**. +- `--data` or `-d` String data to be passed as an event to your function. By default data is read from standard input. +- `--path` or `-p` The path to a json file with input data to be passed to the invoked function. This path is relative to the root directory of the service. +- `--log` or `-l` If set to `true`, it will output logging data of the invocation. Default is `false`. + +## Provided lifecycle events +- `invoke:invoke` + +## Examples + +### Fn + +```bash +serverless invoke --function functionName +``` + +This example will invoke your deployed function on the configured Fn Api Url +endpoint. This will output the result of the invocation in your terminal. + +#### Function invocation with data + +```bash +serverless invoke --function functionName --data '{"name": "Bernie"}' +``` + +#### Function invocation with logging + +```bash +serverless invoke --function functionName --log +``` + +Just like the first example, but will also outputs logging information about your invocation. + +#### Function invocation with data passing + +```bash +serverless invoke --function functionName --path lib/data.json +``` + +This example will pass the json data in the `lib/data.json` file (relative to the root of the service) while invoking +the specified/deployed function. diff --git a/docs/providers/cloudflare-workers/cli-reference/plugin-install.md b/docs/providers/cloudflare-workers/cli-reference/plugin-install.md new file mode 100644 index 00000000000..45040c4d44a --- /dev/null +++ b/docs/providers/cloudflare-workers/cli-reference/plugin-install.md @@ -0,0 +1,42 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/cli-reference/plugin-install) + + +# Plugin Install + +Install a Serverless plugin and add it to the services `plugins` array. By default, a latest version is installed. +If you want a specific version, you can specify `@` as name option. + +**Note:** You might want to change the order of the plugin in the services `plugins` array. + +```bash +serverless plugin install --name pluginName +``` + +## Options +- `--name` or `-n` The plugins name. **Required**. + +## Provided lifecycle events +- `plugin:install:install` + +## Examples + +### Install the `serverless-webpack` plugin + +```bash +serverless plugin install --name serverless-webpack +``` + +### Install a specific version + +```bash +serverless plugin install --name serverless-webpack@3.0.0-rc.2 +``` diff --git a/docs/providers/cloudflare-workers/cli-reference/plugin-list.md b/docs/providers/cloudflare-workers/cli-reference/plugin-list.md new file mode 100644 index 00000000000..c4a12ff1ef4 --- /dev/null +++ b/docs/providers/cloudflare-workers/cli-reference/plugin-list.md @@ -0,0 +1,25 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/cli-reference/plugin-list) + + +# Plugin List + +List all available plugins on the terminal. Connected to the [Serverless plugin registry](https://github.com/serverless/plugins). + +```bash +serverless plugin list +``` + +## Options +- *None* + +## Provided lifecycle events +- `plugin:list:list` diff --git a/docs/providers/cloudflare-workers/cli-reference/plugin-search.md b/docs/providers/cloudflare-workers/cli-reference/plugin-search.md new file mode 100644 index 00000000000..3500b660f85 --- /dev/null +++ b/docs/providers/cloudflare-workers/cli-reference/plugin-search.md @@ -0,0 +1,33 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/cli-reference/plugin-search) + + +# Plugin Search + +Search for a specific plugin based on a search query. Connected to the [Serverless plugin registry](https://github.com/serverless/plugins). + +```bash +serverless plugin search --query query +``` + +## Options +- `--query` or `-q` The query you want to use for your search. **Required**. + +## Provided lifecycle events +- `plugin:search:search` + +## Examples + +### Search for a `sqs` plugin + +```bash +serverless plugin search --query sqs +``` diff --git a/docs/providers/cloudflare-workers/cli-reference/plugin-uninstall.md b/docs/providers/cloudflare-workers/cli-reference/plugin-uninstall.md new file mode 100644 index 00000000000..b7257ecbe89 --- /dev/null +++ b/docs/providers/cloudflare-workers/cli-reference/plugin-uninstall.md @@ -0,0 +1,33 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/cli-reference/plugin-uninstall) + + +# Plugin Uninstall + +Uninstall a Serverless plugin and remove it from the services `plugins` array. + +```bash +serverless plugin uninstall --name pluginName +``` + +## Options +- `--name` or `-n` The plugins name. **Required**. + +## Provided lifecycle events +- `plugin:uninstall:uninstall` + +## Examples + +### Remove the `serverless-webpack` plugin + +```bash +serverless plugin uninstall --name serverless-webpack +``` diff --git a/docs/providers/cloudflare-workers/cli-reference/remove.md b/docs/providers/cloudflare-workers/cli-reference/remove.md new file mode 100644 index 00000000000..2dcfaa6e5a4 --- /dev/null +++ b/docs/providers/cloudflare-workers/cli-reference/remove.md @@ -0,0 +1,21 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/cli-reference/remove) + + +# Cloudflare Workers - Remove +The `serverless remove` command will remove the deployed service, defined in your current working directory, from the provider. + +```bash +serverless remove +``` +It will remove the Cloudflare Worker functions from the Cloudflare. +## Provided lifecycle events +- `remove:remove` diff --git a/docs/providers/cloudflare-workers/events/README.md b/docs/providers/cloudflare-workers/events/README.md new file mode 100644 index 00000000000..171c7a2f811 --- /dev/null +++ b/docs/providers/cloudflare-workers/events/README.md @@ -0,0 +1,18 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/events/) + + +# Serverless Cloudflare Workers Events + +Welcome to the Serverless Cloudflare Workers Events Glossary! + +Please select a section on the left to get started. + +If you have questions, join the [chat in gitter](https://gitter.im/serverless/serverless) or [post over on the forums](http://forum.serverless.com/) + diff --git a/docs/providers/cloudflare-workers/events/http.md b/docs/providers/cloudflare-workers/events/http.md new file mode 100644 index 00000000000..4b5c5fc541e --- /dev/null +++ b/docs/providers/cloudflare-workers/events/http.md @@ -0,0 +1,37 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/events/http) + + + +# Cloudflare Workers - HTTP Events +The only type of event that is supported in Cloudflare Workers is HTTP events, so defining events in your `serverless.yml` is optional. Defined events in your `serverless.yml` are only used by the `serverless invoke` command, which can be useful for testing your Functions. + +## Serverless Yml +When creating a service your serverless yml will define which endpoint is used for your function when you run the [`serverless invoke`](../cli-reference/invoke.md) command. + +```yml +# serverless.yml +... +functions: + helloWorld: + # What the script will be called on Cloudflare + worker: hello + # The name of the script on your machine, omitting the .js file extension + script: helloWorld + events: + - http: + url: example.com/hello/user + method: GET + headers: + greeting: hi +``` + +The events section in the yml above makes it so that the Function helloWorld will be used for request to the `example.com/hello/user` endpoint. This configuration would send a GET request with a header called `greeting` that has a value of `hi` to the `example.com/hello/user` endpoint when you run `serverless invoke -f helloWorld`. \ No newline at end of file diff --git a/docs/providers/cloudflare-workers/guide/README.md b/docs/providers/cloudflare-workers/guide/README.md new file mode 100644 index 00000000000..be51a83a8c9 --- /dev/null +++ b/docs/providers/cloudflare-workers/guide/README.md @@ -0,0 +1,17 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/) + + +# Serverless Cloudflare Workers Guide + +Welcome to the Serverless Cloudflare Workers Guide! + +Get started with the **[Introduction to the Serverless framework](./intro.md)** + +If you have questions, join the [chat in gitter](https://gitter.im/serverless/serverless) or [post over on the forums](http://forum.serverless.com/) diff --git a/docs/providers/cloudflare-workers/guide/debugging.md b/docs/providers/cloudflare-workers/guide/debugging.md new file mode 100644 index 00000000000..76d6f9fbd76 --- /dev/null +++ b/docs/providers/cloudflare-workers/guide/debugging.md @@ -0,0 +1,62 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/debugging) + + +# Cloudflare Workers - Debugging +How can we debug errors in our Cloudflare Workers functions? + +Let's imagine that we have deployed the following code as a Cloudflare Worker function using Serverless: + +```javascript +addEventListener('fetch', event => { + event.respondWith(handleRequest(event.request)) + }) + async function handleRequest(request) { + const answer = request.headers.get("greeting") || "hello" + return new Response(answer + " world") + } + +``` +And its corresponding Serverless yml file: + +```yml +# serverless.yml +... +functions: + helloWorld: + # What the script will be called on Cloudflare + worker: hello + # The name of the script on your machine, omitting the .js file extension + script: helloWorld + events: + - http: + url: example.com/hello/user + # Defines the method used by serverless when the `invoke` command is used. Cloudflare Workers only support GET requests for now + method: GET + headers: + greeting: hi +``` + +Let's invoke correctly that function + +```bash +serverless invoke --function helloWorld + +# Output +hi world +``` + + +If we were to call the above function without any headers, you would get `hello world` back instead of `hi world`, so we know that our worker is properly reading the greeting header. + +## Cloudflare Workers Playground + +Cloudflare Workers also have a [Playground](https://cloudflareworkers.com/#) you can use to modify a Cloudflare Worker and see the results live on the same screen. The Cloudflare Workers Playground is another great way to debug your worker. diff --git a/docs/providers/cloudflare-workers/guide/deploying.md b/docs/providers/cloudflare-workers/guide/deploying.md new file mode 100644 index 00000000000..2910dc74ddc --- /dev/null +++ b/docs/providers/cloudflare-workers/guide/deploying.md @@ -0,0 +1,113 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/deploying) + + +# Cloudflare Workers - Deploying +The Serverless Framework was designed to provision your Cloudflare Workers Functions and Events. It does this via a couple of methods designed for different types of deployments. + +## prerequisites + +In order to deploy your Cloudflare Worker, you need to set your Cloudflare email as an environmental variable called `CLOUDFLARE_AUTH_EMAIL`, and your Cloudflare Global API Key as an environmental variable called `CLOUDFLARE_AUTH_KEY`. + +Environmental variables are variables that live inside your terminal. + +For Mac and Linux users, you can set environmental variables like this: + +```bash +export CLOUDFLARE_AUTH_KEY=YOUR_API_KEY_HERE +export CLOUDFLARE_AUTH_EMAIL=YOUR_CLOUDFLARE_EMAIL +``` + +And for Windows (CMD) users, you can set environmental variables like this: + +```bash +set CLOUDFLARE_AUTH_KEY=YOUR_API_KEY_HERE +set CLOUDFLARE_AUTH_EMAIL=YOUR_CLOUDFLARE_EMAIL +``` + +You’ll need to redefine your environmental variables after each time you close your terminal. + + + +## Deploy All +This is the main method for doing deployments with the Serverless Framework: + +```bash +serverless deploy +``` + +Use this method when you have updated your Function, Event or Resource configuration in `serverless.yml` and you want to deploy that change (or multiple changes at the same time) to your Cloudflare Worker. + +### How It Works +The Serverless Framework reads in `serverless.yml` and uses it to provision your Functions. + +For each defined function in your `serverless.yml` file, the Framework will create a Cloudflare Workers script. + +For example, let's take the following example `serverless.yml` file: + +```yml +# serverless.yml + +service: + name: hello-world + config: + accountId: CLOUDFLARE_ACCOUNT_ID + zoneId: CLOUDFLARE_ZONE_ID + workers: + hello: + routes: + - example.com/hello/* + foo_script: + routes: + - example.com/foo/* + +provider: + name: cloudflare + +plugins: + - serverless-cloudflare-workers + +functions: + helloWorld: + # What the script will be called on Cloudflare + worker: hello + # The name of the script on your machine, omitting the .js file extension + script: helloWorld + # Events are optional to declare and only affect the `serverless invoke` command + events: + - http: + url: example.com/hello/user + method: GET + headers: + greeting: hi + + + # Only Enterprise accounts would be allowed to add this second function + foo: + worker: foo_script + script: bar + events: + - http: + url: example.com/foo/bar + method: GET +``` + +After deploying that file, you’ll be able to hit the specified top-level routes of your zone, `example.com/hello/*` and `example.com/foo/*`, and any endpoints that resolve to these routes, like `example.com/hello/user` and `example.com/foo/bar`. + +## Deploy Function +This deployment method updates or deploys a single function. It performs the platform API call to deploy your package without the other resources. It is much faster than re-deploying your whole service each time. + +```bash +serverless deploy --function myFunction +``` + +### Tips +Check out the [deploy command docs](../cli-reference/deploy.md) for all details and options. diff --git a/docs/providers/cloudflare-workers/guide/events.md b/docs/providers/cloudflare-workers/guide/events.md new file mode 100644 index 00000000000..1b6e636be30 --- /dev/null +++ b/docs/providers/cloudflare-workers/guide/events.md @@ -0,0 +1,39 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/events) + + + +# Cloudflare Workers - Events +Simply put, events are the things that trigger your functions to run. Currently, they are optional to define and are only used by the `serverless invoke` command, which can be useful for testing your Functions. + +If you are using Cloudflare Workers as your provider, all `events` in the service are HTTP Events, because that is the only event that Cloudflare Workers currently support. + +```yml +# serverless.yml +… + +functions: + helloWorld: + # What the script will be called on Cloudflare + worker: hello + # The name of the script on your machine, omitting the .js file extension + script: helloWorld + events: + - http: + url: example.com/hello/user + method: GET + headers: + greeting: hi +``` + +Then [`serverless invoke -f helloWorld`](../cli-reference/invoke.md) will make a GET request to `example.com/hello/user` with a header called `greeting` that has a value of `hi`. + +[View the Cloudflare Workers events section for more information on HTTP events](../events). diff --git a/docs/providers/cloudflare-workers/guide/functions.md b/docs/providers/cloudflare-workers/guide/functions.md new file mode 100644 index 00000000000..340e24ad4f0 --- /dev/null +++ b/docs/providers/cloudflare-workers/guide/functions.md @@ -0,0 +1,119 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/functions) + + +# Cloudflare Workers - Functions + +If you are using Cloudflare as a provider, all *functions* inside the service are Cloudflare Workers. + +## Configuration + +All of the Cloudflare Workers in your serverless service can be found in `serverless.yml` under the `functions` property. + +```yml +# serverless.yml + +service: + name: hello-world + config: + accountId: CLOUDFLARE_ACCOUNT_ID + zoneId: CLOUDFLARE_ZONE_ID + workers: + hello: + routes: + - example.com/hello/* + +provider: + name: cloudflare + +plugins: + - serverless-cloudflare-workers + +functions: + helloWorld: + # What the script will be called on Cloudflare + worker: hello + # The name of the script on your machine, omitting the .js file extension + script: helloWorld + # Events are only relevant to the `serverless invoke` command and don’t affect deployment in any way + events: + - http: + url: example.com/hello/user + method: GET + headers: + someKey: someValue +``` + +The `script` property points to the file containing your Cloudflare Worker. + +```javascript +// helloWorld.js + +addEventListener('fetch', event => { + event.respondWith(handleRequest(event.request)) + }) + + async function handleRequest(request) { + return new Response("Hello world") + } +``` + +If you have an Enterprise Cloudflare account, you can add multiple Cloudflare Workers to your project. + +```yml +# serverless.yml + +service: + name: hello-world + config: + accountId: CLOUDFLARE_ACCOUNT_ID + zoneId: CLOUDFLARE_ZONE_ID + workers: + hello: + routes: + - example.com/hello/* + foo_script: + routes: + - example.com/foo/* + +provider: + name: cloudflare + +plugins: + - serverless-cloudflare-workers + +functions: + helloWorld: + # What the script will be called on Cloudflare + worker: hello + # The name of the script on your machine, omitting the .js file extension + script: helloWorld + # Events are only relevant to the `serverless invoke` command and don’t affect deployment in any way + events: + - http: + url: example.com/hello/user + method: GET + headers: + someKey: someValue + + + # Only Enterprise accounts would be allowed to add this second function and its corresponding route above + foo: + worker: foo_script + script: bar + events: + - http: + url: example.com/foo/bar + method: GET +``` +The `script` property is what the Cloudflare Worker will be called on Cloudflare’s data centers. + +The `events` property is optional and is only relevant for using the `serverless invoke` command. Check out the [`events`](./events.md) guide for more information. diff --git a/docs/providers/cloudflare-workers/guide/installation.md b/docs/providers/cloudflare-workers/guide/installation.md new file mode 100644 index 00000000000..ffc0b92aa73 --- /dev/null +++ b/docs/providers/cloudflare-workers/guide/installation.md @@ -0,0 +1,57 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/installation) + + +# Cloudflare Workers - Installation + +## Installing Cloudflare Workers +Cloudflare Workers don’t actually require any installation to run. However, You will need to set your Global API key from Cloudflare as an environmental variable named `CLOUDFLARE_AUTH_KEY`, and your Cloudflare account email as an environmental variable named `CLOUDFLARE_AUTH_EMAIL`. You can get your Global API key from your [Cloudflare profile](https://dash.cloudflare.com/profile) page. + +Environmental variables are variables that live inside your terminal. + +For Mac and Linux users, you can set environmental variables like this: + +```bash +export CLOUDFLARE_AUTH_KEY=YOUR_API_KEY_HERE +export CLOUDFLARE_AUTH_EMAIL=YOUR_CLOUDFLARE_EMAIL +``` + +And for Windows (CMD) users, you can set environmental variables like this: + +```bash +set CLOUDFLARE_AUTH_KEY=YOUR_API_KEY_HERE +set CLOUDFLARE_AUTH_EMAIL=YOUR_CLOUDFLARE_EMAIL +``` + +You’ll need to redefine your environmental variables after each time you close your terminal. + +## Installing the Serverless Framework +Next, install the Serverless Framework via [npm](https://npmjs.org) which was already installed when you installed Node.js. + +Open up a terminal and type `npm install -g serverless` to install Serverless. + +```bash +npm install -g serverless +``` + +Once the installation process is done you can verify that Serverless is installed successfully by running the following command in your terminal: + +```bash +serverless +``` + +To see which version of serverless you have installed run: + +```bash +serverless --version +``` + +Remember, you need version 1.31 to use Cloudflare Workers with Serverless. diff --git a/docs/providers/cloudflare-workers/guide/intro.md b/docs/providers/cloudflare-workers/guide/intro.md new file mode 100644 index 00000000000..f238916f38e --- /dev/null +++ b/docs/providers/cloudflare-workers/guide/intro.md @@ -0,0 +1,108 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/intro) + + + +# Cloudflare Workers - Introduction + +The Serverless Framework helps you develop and deploy serverless applications using Cloudflare Workers. It's a CLI that offers structure, automation, and best practices out-of-the-box, allowing you to focus on building sophisticated, event-driven, serverless architectures, comprised of [Functions](#functions) and [Events](#events). + +The Serverless Framework is different than other application frameworks because: +* It manages your code as well as your infrastructure +* It supports multiple languages (Although Cloudflare Workers only supports Javascript for now) + +## Core Concepts +Here are the Serverless Framework's main concepts and how they pertain to Cloudflare Workers. + +### Functions +A Function is a Cloudflare Worker. It's an independent unit of deployment, like a microservice. It's merely code, deployed on Cloudflare’s 151+ PoPs (points of presence), that is most often written to perform a single job, such as: +* *Performing A/B Testing* +* *Custom routing based on user location, custom headers, etc.* +* *Hosting webhook endpoints* + +### Events +Anything that triggers a Cloudflare Worker Event to execute is regarded by the Framework as an **Event**. The only event that triggers a Cloudflare Worker is an HTTP request. Since the only event that can trigger a Worker is an HTTP request, declaring events is optional, and only used to declare specific endpoints that can be called by [`serverless invoke`](../cli-reference/invoke.md). This is useful for defining specific hooks into your application for testing. + +### Services +A **Service** is the Serverless Framework's unit of organization. You can think of it as a project file, though you can have multiple services for a single application. It's where you define your Functions and the routes they will live on, all in one file entitled `serverless.yml`. Non-Enterprise Cloudflare accounts can only deploy one function (that can be deployed to multiple routes), while Enterprise Cloudflare accounts can deploy multiple functions at once: + +```yml +# serverless.yml + +service: + name: hello-world + config: + accountId: CLOUDFLARE_ACCOUNT_ID + zoneId: CLOUDFLARE_ZONE_ID + workers: + hello: + routes: + - example.com/hello/* + foo_script: + routes: + - example.com/foo/* + +provider: + name: cloudflare + +plugins: + - serverless-cloudflare-workers + +functions: + helloWorld: + # What the script will be called on Cloudflare + worker: hello + # The name of the script on your machine, omitting the .js file extension + script: helloWorld + # Events are only relevant to the `serverless invoke` command and don’t affect deployment in any way + events: + - http: + url: example.com/hello/user + method: GET + headers: + someKey: someValue + + + # Only Enterprise accounts would be allowed to add this second function and its corresponding route above + foo: + worker: foo_script + script: bar + events: + - http: + url: example.com/foo/bar + method: GET +``` + +You get your `accountId` by grabbing it from the URL when using the [Cloudflare dashboard](https://dash.cloudflare.com), and your `zoneId` from the `overview` tab after selecting the desired zone from the [Cloudflare dashboard](https://dash.cloudflare.com). + +You will also need to set your Global API key from Cloudflare as an environmental variable named `CLOUDFLARE_AUTH_KEY`, and your Cloudflare account email as an environmental variable named `CLOUDFLARE_AUTH_EMAIL`. You can get your Global API key from your [Cloudflare profile](https://dash.cloudflare.com/profile) page. + +Environmental variables are variables that live inside your terminal. + +For Mac and Linux users, you can set environmental variables like this: + +```bash +export CLOUDFLARE_AUTH_KEY=YOUR_API_KEY_HERE +export CLOUDFLARE_AUTH_EMAIL=YOUR_CLOUDFLARE_EMAIL +``` + +And for Windows (CMD) users, you can set environmental variables like this: + +```bash +set CLOUDFLARE_AUTH_KEY=YOUR_API_KEY_HERE +set CLOUDFLARE_AUTH_EMAIL=YOUR_CLOUDFLARE_EMAIL +``` + +You’ll need to redefine your environmental variables after each time you close your terminal. + +If you’re not an enterprise customer and you want to execute different code on multiple routes with only one funciton, we recommend writing code based off of our [conditional routing](https://developers.cloudflare.com/workers/recipes/conditional-routing/) template to check your route and execute different code accordingly. You can also write workers in separate files and compile it into one worker with [webpack](https://developers.cloudflare.com/workers/writing-workers/using-npm-modules/). + +When you deploy with the Framework by running `serverless deploy`, everything in `serverless.yml` is deployed at once. diff --git a/docs/providers/cloudflare-workers/guide/quick-start.md b/docs/providers/cloudflare-workers/guide/quick-start.md new file mode 100644 index 00000000000..a670f05b749 --- /dev/null +++ b/docs/providers/cloudflare-workers/guide/quick-start.md @@ -0,0 +1,105 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/quick-start) + + +# Cloudflare Workers - Quickstart + +## Pre-requisites +Node.js `v6.5.0` or later. +Serverless CLI `v1.31` or later. You can run `npm install -g serverless` to install it. + +## Create a new service +Create a new service using either the `cloudflare-workers` or `cloudflare-workers-enterprise` template, depending on your Cloudflare domain’s plan level, and specifying a unique name and an optional path for your service. + +```bash +# Create a new Serverless Service/Project +$ serverless create --template cloudflare-workers --path new-project +# Change into the newly created directory +$ cd new-project +# Install npm dependencies +$ npm install +``` + +Note: there are two templates for Cloudflare Workers: `cloudflare-workers` and `cloudflare-workers-enterprise`. The enterprise template sets up a project that can natively deploy [multiple scripts](https://developers.cloudflare.com/workers/api/config-api-for-enterprise/), each with their own routes. It requires an enterprise Cloudflare account to use. + +The `cloudflare-workers` template still supports [conditional routing](https://developers.cloudflare.com/workers/recipes/conditional-routing/) and multiple scripts if you use a tool like [webpack](https://developers.cloudflare.com/workers/writing-workers/using-npm-modules/). + +## Deploy, test and diagnose your service + +You will need to set your Global API key from Cloudflare as an environmental variable named `CLOUDFLARE_AUTH_KEY`, and your Cloudflare account email as an environmental variable named `CLOUDFLARE_AUTH_EMAIL`. You can get your Global API key from your [Cloudflare profile](https://dash.cloudflare.com/profile) page. + +Environmental variables are variables that live inside your terminal. + +For Mac and Linux users, you can set environmental variables like this: + +```bash +export CLOUDFLARE_AUTH_KEY=YOUR_API_KEY_HERE +export CLOUDFLARE_AUTH_EMAIL=YOUR_CLOUDFLARE_EMAIL +``` + +And for Windows (CMD) users, you can set environmental variables like this: + +```bash +set CLOUDFLARE_AUTH_KEY=YOUR_API_KEY_HERE +set CLOUDFLARE_AUTH_EMAIL=YOUR_CLOUDFLARE_EMAIL +``` + +You’ll need to redefine your environmental variables after each time you close your terminal. + +1. **Deploy the Service** + +Use this when you have made changes to your Functions, Events or Resources in `serverless.yml` or you simply want to deploy all changes within your Service at the same time. + +```bash +serverless deploy +``` + +2. **Deploy the Function** + +Use this to quickly upload and overwrite your function code, allowing you to develop faster. + +```bash +serverless deploy -f hello +``` + +3. **Invoke the Function** + +Invokes the Function and returns results. + +```bash +serverless invoke --function helloWorld + +Hello world +``` + +Note that for `invoke`, your Function must have the `events` field populated in order for the `serverless` tool to know exactly which route to request. Defining the `headers` field is optional. + +```yml +# serverless.yml +... +foo: + worker: foo_script + script: bar + events: + - http: + url: example.com/foo/bar + method: GET + headers: + someKey: someValue +``` + + +## Cleanup +If at any point, you no longer need your service, you can run the following command to remove the Functions, Events and Resources that were created. + +```bash +serverless remove +``` diff --git a/docs/providers/cloudflare-workers/guide/services.md b/docs/providers/cloudflare-workers/guide/services.md new file mode 100644 index 00000000000..f1b45a6e7c1 --- /dev/null +++ b/docs/providers/cloudflare-workers/guide/services.md @@ -0,0 +1,202 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/services) + + +# Cloudflare Workers - Services + +A `service` is like a project. It's where you define your Cloudflare Workers and the `events` you test them with, all in a file called `serverless.yml`. + +To get started building your first Serverless Framework project, create a `service`. + +## Organization + +In the beginning of an application created by a team with an Enterprise Cloudflare account, and for the lifespan of an application made by a team with a Non-Enterprise Cloudflare account, we recommend you use a single Service to define all of the Functions and Events for that project. + +```bash +myService/ + serverless.yml # Contains all functions and infrastructure resources +``` + +However, as your application grows as an Enterprise Cloudflare user, you can break it out into multiple services. A lot of people organize their services by workflows or data models, and group the functions related to those workflows and data models together in the service. + +```bash +users/ + serverless.yml # Contains 4 functions that do Users CRUD operations and the Users database +posts/ + serverless.yml # Contains 4 functions that do Posts CRUD operations and the Posts database +comments/ + serverless.yml # Contains 4 functions that do Comments CRUD operations and the Comments database +``` + +This makes sense since related functions usually use common infrastructure resources, and you want to keep those functions and resources together as a single unit of deployment, for better organization and separation of concerns. + +## Creation + +To create a service, use the `create` command. You can also pass in a path to create a directory and auto-name your service: + +```bash +# Create service with cloudflare-workers template in the folder ./my-service +serverless create --template cloudflare-workers --path my-service +``` + +Here are the available runtimes for Cloudflare Workers: + +* cloudflare-workers +* cloudflare-workers-enterprise + +Check out the [create command docs](../cli-reference/create) for all the details and options. + +## Contents + +You'll see the following files in your working directory: + +- `serverless.yml` +- `helloWorld.js` + +### serverless.yml + +Each `service` configuration is managed in the `serverless.yml` file. The main responsibilities of this file are: + +- Declare a Serverless service +- Define one or more functions in the service + - Define the provider the service will be deployed to + - Define any custom plugins to be used + - Define events that trigger each function to execute (e.g. HTTP requests) + - Allow events listed in the `events` section to automatically create the resources required for the `serverless invoke` command + +You can see the name of the service, the provider configuration and the first function inside the `functions` definition. Any further service configuration will be done in this file. + +```yml +# serverless.yml + +service: + name: hello-world + config: + accountId: CLOUDFLARE_ACCOUNT_ID + zoneId: CLOUDFLARE_ZONE_ID + workers: + hello: + routes: + - example.com/hello/* + foo_script: + routes: + - example.com/foo/* + +provider: + name: cloudflare + +plugins: + - serverless-cloudflare-workers + +functions: + helloWorld: + # What the script will be called on Cloudflare + worker: hello + # The name of the script on your machine, omitting the .js file extension + script: helloWorld + # Events are only relevant to the `serverless invoke` command and don’t affect deployment in any way + events: + - http: + url: example.com/hello/user + method: GET + headers: + someKey: someValue + + + # Only Enterprise accounts would be allowed to add this second function and its corresponding route above + foo: + worker: foo_script + script: bar + events: + - http: + url: example.com/foo/bar + method: GET + +``` + +### helloWorld.js + +The `helloWorld.js` file contains a barebones Cloudflare Worker that returns ‘hello world’. + +## Deployment + +When you deploy a Service, all of the Functions, and Events in your `serverless.yml` are translated into calls to Cloudflare to create your Cloudflare Worker(s). + +To deploy a service, first `cd` into the relevant service directory: + +```bash +cd my-service +``` + +Then use the `deploy` command: + +```bash +serverless deploy +``` + +Check out the [deployment guide](./deploying.md) to learn more about deployments and how they work. Or, check out the [deploy command docs](../cli-reference/deploy.md) for all the details and options. + +## Removal + +To easily remove your Service from Cloudflare’s data centers, you can use the `remove` command. + +Run `serverless remove` to trigger the removal process. + +Serverless will start the removal and informs you about it's process on the console. A success message is printed once the whole service is removed. + +The removal process will only remove the service on your provider's infrastructure. The service directory will still remain on your local machine so you can still modify and (re)deploy it to another stage, region or provider later on. + +## Version Pinning + +The Serverless framework is usually installed globally via `npm install -g serverless`. This way you have the Serverless CLI available for all your services. + +Installing tools globally has the downside that the version can't be pinned inside package.json. This can lead to issues if you upgrade Serverless, but your colleagues or CI system don't. You can use a feature in your serverless.yml without worrying that your CI system will deploy with an old version of Serverless. + +### Pinning a Version + +To configure version pinning define a `frameworkVersion` property in your serverless.yaml. Whenever you run a Serverless command from the CLI it checks if your current Serverless version is matching the `frameworkVersion` range. The CLI uses [Semantic Versioning](http://semver.org/) so you can pin it to an exact version or provide a range. In general we recommend to pin to an exact version to ensure everybody in your team has the exact same setup and no unexpected problems happen. + +### Examples + +#### Exact Version + +```yml +# serverless.yml + +frameworkVersion: "=1.0.3" +``` + +#### Version Range + +```yml +# serverless.yml + +frameworkVersion: ">=1.0.0 <2.0.0" +``` + + +## Installing Serverless in an existing service + +If you already have a Serverless service, and would prefer to lock down the framework version using `package.json`, then you can install Serverless as follows: + +```bash +# from within a service +npm install serverless --save-dev +``` + +### Invoking Serverless locally + +To execute the locally installed Serverless executable you have to reference the binary out of the node modules directory. + +Example: +``` +node ./node_modules/serverless/bin/serverless deploy +``` diff --git a/docs/providers/cloudflare-workers/guide/workflow.md b/docs/providers/cloudflare-workers/guide/workflow.md new file mode 100644 index 00000000000..2b5fe37a78e --- /dev/null +++ b/docs/providers/cloudflare-workers/guide/workflow.md @@ -0,0 +1,58 @@ + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/workflow) + + + +# Cloudflare Workers - Workflow +Generally, Cloudflare Workers can be written locally, deployed with serverless, and tested with the [`serverless invoke`](../cli-reference/invoke.md) command. However, using the [Cloudflare Workers Playground](https://cloudflareworkers.com/#) can help you test and view your worker’s results live if you need more insight while developing your Cloudflare Worker. + +Below is a list of general tips for developing Cloudflare Workers with Serverless. + +### Development Workflow +Write your functions +Use `serverless deploy` only when you've made changes to `serverless.yml` and in CI/CD systems. +Use `serverless deploy -f myFunction` to rapidly deploy changes when you are working on a specific Cloudflare Workers Function. +Use `serverless invoke -f myFunction` to test your Cloudflare Workers Functions. +### Larger Projects +* For Non-Enterprise Cloudflare customers, combining multiple workers into one file or using [webpack](https://developers.cloudflare.com/workers/writing-workers/using-npm-modules/). +* Keep the Functions and Resources in your Serverless Services to a minimum. +## Cheat Sheet +A handy list of commands to use when developing with the Serverless Framework. + +##### Create A Service: +Creates a new Service: + +```bash +serverless create -p [SERVICE NAME] -t cloudflare-workers +``` + +##### Deploy All +Use this when you have made changes to your Functions, Events or Resources in `serverless.yml` or you simply want to deploy all changes within your Service at the same time. + +```bash +serverless deploy +``` + + +##### Deploy Function +Use this to quickly overwrite your Cloudflare Workers Functions, allowing you to develop faster if you have an Enterprise account that supports deploying multiple functions. + +```bash +serverless deploy -f [FUNCTION NAME] +``` + + +##### Invoke Function +Invokes a Cloudflare Workers Function. + +```bash +serverless invoke -f [FUNCTION NAME] +``` From 46ca914623d04039a55646818b0bc103b284811c Mon Sep 17 00:00:00 2001 From: Raees Date: Thu, 6 Sep 2018 17:59:52 +0500 Subject: [PATCH 04/18] Add instructions to get and add zoneId --- docs/providers/cloudflare-workers/cli-reference/deploy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/providers/cloudflare-workers/cli-reference/deploy.md b/docs/providers/cloudflare-workers/cli-reference/deploy.md index 50a8773e208..e88cbf2482c 100644 --- a/docs/providers/cloudflare-workers/cli-reference/deploy.md +++ b/docs/providers/cloudflare-workers/cli-reference/deploy.md @@ -12,7 +12,7 @@ layout: Doc # Cloudflare Workers - Deploy -In order to be able to deploy any Cloudflare Workers, You will need to set your Global API key from Cloudflare as an environmental variable named `CLOUDFLARE_AUTH_KEY`, and your Cloudflare account email as an environmental variable named `CLOUDFLARE_AUTH_EMAIL`. You can get your Global API key from your [Cloudflare profile](https://dash.cloudflare.com/profile) page. +In order to be able to deploy any Cloudflare Workers, You will need to set your Global API key from Cloudflare as an environmental variable named `CLOUDFLARE_AUTH_KEY`, and your Cloudflare account email as an environmental variable named `CLOUDFLARE_AUTH_EMAIL`. You can get your Global API key from your [Cloudflare profile](https://dash.cloudflare.com/profile) page. You will also need to set `zoneId` for your domain name in `serverless.yml` under `service.config`, the `zoneId` can be found from the overview tab after selecting the desired zone from the [Cloudflare dashboard](https://dash.cloudflare.com/). Environmental variables are variables that live inside your terminal. From 4d29e1b7387a446c71a90c29784db57de42217a9 Mon Sep 17 00:00:00 2001 From: Raees Date: Thu, 6 Sep 2018 18:19:13 +0500 Subject: [PATCH 05/18] Add zoneId instructions to quickstart --- docs/providers/cloudflare-workers/guide/quick-start.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/providers/cloudflare-workers/guide/quick-start.md b/docs/providers/cloudflare-workers/guide/quick-start.md index a670f05b749..d5c169da3d6 100644 --- a/docs/providers/cloudflare-workers/guide/quick-start.md +++ b/docs/providers/cloudflare-workers/guide/quick-start.md @@ -34,7 +34,7 @@ The `cloudflare-workers` template still supports [conditional routing](https://d ## Deploy, test and diagnose your service -You will need to set your Global API key from Cloudflare as an environmental variable named `CLOUDFLARE_AUTH_KEY`, and your Cloudflare account email as an environmental variable named `CLOUDFLARE_AUTH_EMAIL`. You can get your Global API key from your [Cloudflare profile](https://dash.cloudflare.com/profile) page. +You will need to set your Global API key from Cloudflare as an environmental variable named `CLOUDFLARE_AUTH_KEY`, and your Cloudflare account email as an environmental variable named `CLOUDFLARE_AUTH_EMAIL`. You can get your Global API key from your [Cloudflare profile](https://dash.cloudflare.com/profile) page. You will also need to set `zoneId` for your domain name in `serverless.yml` under `service.config`, the `zoneId` can be found from the overview tab after selecting the desired zone from the [Cloudflare dashboard](https://dash.cloudflare.com/). Environmental variables are variables that live inside your terminal. From c33d42d9514687f6e013e17d39fcc44835867235 Mon Sep 17 00:00:00 2001 From: Raees Iqbal <10067728+raeesbhatti@users.noreply.github.com> Date: Fri, 7 Sep 2018 15:36:04 +0500 Subject: [PATCH 06/18] Add instructions for getting accountId as well --- docs/providers/cloudflare-workers/cli-reference/deploy.md | 2 +- docs/providers/cloudflare-workers/guide/quick-start.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/providers/cloudflare-workers/cli-reference/deploy.md b/docs/providers/cloudflare-workers/cli-reference/deploy.md index e88cbf2482c..329c42d2042 100644 --- a/docs/providers/cloudflare-workers/cli-reference/deploy.md +++ b/docs/providers/cloudflare-workers/cli-reference/deploy.md @@ -12,7 +12,7 @@ layout: Doc # Cloudflare Workers - Deploy -In order to be able to deploy any Cloudflare Workers, You will need to set your Global API key from Cloudflare as an environmental variable named `CLOUDFLARE_AUTH_KEY`, and your Cloudflare account email as an environmental variable named `CLOUDFLARE_AUTH_EMAIL`. You can get your Global API key from your [Cloudflare profile](https://dash.cloudflare.com/profile) page. You will also need to set `zoneId` for your domain name in `serverless.yml` under `service.config`, the `zoneId` can be found from the overview tab after selecting the desired zone from the [Cloudflare dashboard](https://dash.cloudflare.com/). +In order to be able to deploy any Cloudflare Workers, You will need to set your Global API key from Cloudflare as an environmental variable named `CLOUDFLARE_AUTH_KEY`, and your Cloudflare account email as an environmental variable named `CLOUDFLARE_AUTH_EMAIL`. You can get your Global API key from your [Cloudflare profile](https://dash.cloudflare.com/profile) page. You will also need to set `accountId` and `zoneId` in `serverless.yml` under `service.config`, the first part of the path when you open [Cloudflare dashboard] as a logged in user is your `accountId`, e.g. `dash.cloudflare.com/{accountId}`. And the `zoneId` can be found from the overview tab after selecting the desired zone from the [Cloudflare dashboard](https://dash.cloudflare.com/). Environmental variables are variables that live inside your terminal. diff --git a/docs/providers/cloudflare-workers/guide/quick-start.md b/docs/providers/cloudflare-workers/guide/quick-start.md index d5c169da3d6..702f34b73cb 100644 --- a/docs/providers/cloudflare-workers/guide/quick-start.md +++ b/docs/providers/cloudflare-workers/guide/quick-start.md @@ -34,7 +34,7 @@ The `cloudflare-workers` template still supports [conditional routing](https://d ## Deploy, test and diagnose your service -You will need to set your Global API key from Cloudflare as an environmental variable named `CLOUDFLARE_AUTH_KEY`, and your Cloudflare account email as an environmental variable named `CLOUDFLARE_AUTH_EMAIL`. You can get your Global API key from your [Cloudflare profile](https://dash.cloudflare.com/profile) page. You will also need to set `zoneId` for your domain name in `serverless.yml` under `service.config`, the `zoneId` can be found from the overview tab after selecting the desired zone from the [Cloudflare dashboard](https://dash.cloudflare.com/). +You will need to set your Global API key from Cloudflare as an environmental variable named `CLOUDFLARE_AUTH_KEY`, and your Cloudflare account email as an environmental variable named `CLOUDFLARE_AUTH_EMAIL`. You can get your Global API key from your [Cloudflare profile](https://dash.cloudflare.com/profile) page. You will also need to set `accountId` and `zoneId` in `serverless.yml` under `service.config`, the first part of the path when you open [Cloudflare dashboard] as a logged in user is your `accountId`, e.g. `dash.cloudflare.com/{accountId}`. And the `zoneId` can be found from the overview tab after selecting the desired zone from the [Cloudflare dashboard](https://dash.cloudflare.com/). Environmental variables are variables that live inside your terminal. From 61797bf38265ca7680ca3027b0715caaa8a03afa Mon Sep 17 00:00:00 2001 From: Raees Iqbal <10067728+raeesbhatti@users.noreply.github.com> Date: Fri, 7 Sep 2018 15:36:28 +0500 Subject: [PATCH 07/18] Add accountId and zoneId instructions to deploying guide --- docs/providers/cloudflare-workers/guide/deploying.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/providers/cloudflare-workers/guide/deploying.md b/docs/providers/cloudflare-workers/guide/deploying.md index 2910dc74ddc..29ccf61b8db 100644 --- a/docs/providers/cloudflare-workers/guide/deploying.md +++ b/docs/providers/cloudflare-workers/guide/deploying.md @@ -15,7 +15,7 @@ The Serverless Framework was designed to provision your Cloudflare Workers Funct ## prerequisites -In order to deploy your Cloudflare Worker, you need to set your Cloudflare email as an environmental variable called `CLOUDFLARE_AUTH_EMAIL`, and your Cloudflare Global API Key as an environmental variable called `CLOUDFLARE_AUTH_KEY`. +In order to deploy your Cloudflare Worker, you need to set your Cloudflare email as an environmental variable called `CLOUDFLARE_AUTH_EMAIL`, and your Cloudflare Global API Key as an environmental variable called `CLOUDFLARE_AUTH_KEY`. You will also need to set `accountId` and `zoneId` in `serverless.yml` under `service.config`, the first part of the path when you open [Cloudflare dashboard] as a logged in user is your `accountId`, e.g. `dash.cloudflare.com/{accountId}`. And the `zoneId` can be found from the overview tab after selecting the desired zone from the [Cloudflare dashboard](https://dash.cloudflare.com/). Environmental variables are variables that live inside your terminal. From 87a09d397c4dcd502c4cd07a4888bf20dbc03015 Mon Sep 17 00:00:00 2001 From: Raees Iqbal <10067728+raeesbhatti@users.noreply.github.com> Date: Fri, 7 Sep 2018 15:43:32 +0500 Subject: [PATCH 08/18] Update instructions a bit --- docs/providers/cloudflare-workers/cli-reference/deploy.md | 2 +- docs/providers/cloudflare-workers/guide/deploying.md | 2 +- docs/providers/cloudflare-workers/guide/quick-start.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/providers/cloudflare-workers/cli-reference/deploy.md b/docs/providers/cloudflare-workers/cli-reference/deploy.md index 329c42d2042..d2040a7d071 100644 --- a/docs/providers/cloudflare-workers/cli-reference/deploy.md +++ b/docs/providers/cloudflare-workers/cli-reference/deploy.md @@ -12,7 +12,7 @@ layout: Doc # Cloudflare Workers - Deploy -In order to be able to deploy any Cloudflare Workers, You will need to set your Global API key from Cloudflare as an environmental variable named `CLOUDFLARE_AUTH_KEY`, and your Cloudflare account email as an environmental variable named `CLOUDFLARE_AUTH_EMAIL`. You can get your Global API key from your [Cloudflare profile](https://dash.cloudflare.com/profile) page. You will also need to set `accountId` and `zoneId` in `serverless.yml` under `service.config`, the first part of the path when you open [Cloudflare dashboard] as a logged in user is your `accountId`, e.g. `dash.cloudflare.com/{accountId}`. And the `zoneId` can be found from the overview tab after selecting the desired zone from the [Cloudflare dashboard](https://dash.cloudflare.com/). +In order to be able to deploy any Cloudflare Workers, You will need to set your Global API key from Cloudflare as an environmental variable named `CLOUDFLARE_AUTH_KEY`, and your Cloudflare account email as an environmental variable named `CLOUDFLARE_AUTH_EMAIL`. You can get your Global API key from your [Cloudflare profile](https://dash.cloudflare.com/profile) page. You will also need to set `accountId` and `zoneId` in `serverless.yml` under `service.config`. The first part of the path when you open [Cloudflare dashboard](https://dash.cloudflare.com/) as a logged in user is your `accountId`, e.g. `dash.cloudflare.com/{accountId}`. And the `zoneId` can be found from the overview tab after selecting the desired zone from the [Cloudflare dashboard](https://dash.cloudflare.com/). Environmental variables are variables that live inside your terminal. diff --git a/docs/providers/cloudflare-workers/guide/deploying.md b/docs/providers/cloudflare-workers/guide/deploying.md index 29ccf61b8db..f92ac7572da 100644 --- a/docs/providers/cloudflare-workers/guide/deploying.md +++ b/docs/providers/cloudflare-workers/guide/deploying.md @@ -15,7 +15,7 @@ The Serverless Framework was designed to provision your Cloudflare Workers Funct ## prerequisites -In order to deploy your Cloudflare Worker, you need to set your Cloudflare email as an environmental variable called `CLOUDFLARE_AUTH_EMAIL`, and your Cloudflare Global API Key as an environmental variable called `CLOUDFLARE_AUTH_KEY`. You will also need to set `accountId` and `zoneId` in `serverless.yml` under `service.config`, the first part of the path when you open [Cloudflare dashboard] as a logged in user is your `accountId`, e.g. `dash.cloudflare.com/{accountId}`. And the `zoneId` can be found from the overview tab after selecting the desired zone from the [Cloudflare dashboard](https://dash.cloudflare.com/). +In order to deploy your Cloudflare Worker, you need to set your Cloudflare email as an environmental variable called `CLOUDFLARE_AUTH_EMAIL`, and your Cloudflare Global API Key as an environmental variable called `CLOUDFLARE_AUTH_KEY`. You will also need to set `accountId` and `zoneId` in `serverless.yml` under `service.config`. The first part of the path when you open [Cloudflare dashboard](https://dash.cloudflare.com/) as a logged in user is your `accountId`, e.g. `dash.cloudflare.com/{accountId}`. And the `zoneId` can be found from the overview tab after selecting the desired zone from the [Cloudflare dashboard](https://dash.cloudflare.com/). Environmental variables are variables that live inside your terminal. diff --git a/docs/providers/cloudflare-workers/guide/quick-start.md b/docs/providers/cloudflare-workers/guide/quick-start.md index 702f34b73cb..f382901ee2a 100644 --- a/docs/providers/cloudflare-workers/guide/quick-start.md +++ b/docs/providers/cloudflare-workers/guide/quick-start.md @@ -34,7 +34,7 @@ The `cloudflare-workers` template still supports [conditional routing](https://d ## Deploy, test and diagnose your service -You will need to set your Global API key from Cloudflare as an environmental variable named `CLOUDFLARE_AUTH_KEY`, and your Cloudflare account email as an environmental variable named `CLOUDFLARE_AUTH_EMAIL`. You can get your Global API key from your [Cloudflare profile](https://dash.cloudflare.com/profile) page. You will also need to set `accountId` and `zoneId` in `serverless.yml` under `service.config`, the first part of the path when you open [Cloudflare dashboard] as a logged in user is your `accountId`, e.g. `dash.cloudflare.com/{accountId}`. And the `zoneId` can be found from the overview tab after selecting the desired zone from the [Cloudflare dashboard](https://dash.cloudflare.com/). +You will need to set your Global API key from Cloudflare as an environmental variable named `CLOUDFLARE_AUTH_KEY`, and your Cloudflare account email as an environmental variable named `CLOUDFLARE_AUTH_EMAIL`. You can get your Global API key from your [Cloudflare profile](https://dash.cloudflare.com/profile) page. You will also need to set `accountId` and `zoneId` in `serverless.yml` under `service.config`. The first part of the path when you open [Cloudflare dashboard](https://dash.cloudflare.com/) as a logged in user is your `accountId`, e.g. `dash.cloudflare.com/{accountId}`. And the `zoneId` can be found from the overview tab after selecting the desired zone from the [Cloudflare dashboard](https://dash.cloudflare.com/). Environmental variables are variables that live inside your terminal. From c4f358cb6a07b60b71288b04e7d7bb452c379c13 Mon Sep 17 00:00:00 2001 From: Stephen Pinkerton Date: Mon, 10 Sep 2018 16:55:41 -0700 Subject: [PATCH 09/18] Update version in docs --- docs/providers/cloudflare-workers/guide/installation.md | 2 +- docs/providers/cloudflare-workers/guide/quick-start.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/providers/cloudflare-workers/guide/installation.md b/docs/providers/cloudflare-workers/guide/installation.md index ffc0b92aa73..b2f8f312b84 100644 --- a/docs/providers/cloudflare-workers/guide/installation.md +++ b/docs/providers/cloudflare-workers/guide/installation.md @@ -54,4 +54,4 @@ To see which version of serverless you have installed run: serverless --version ``` -Remember, you need version 1.31 to use Cloudflare Workers with Serverless. +Remember, you need at least version 1.31.0 to use Cloudflare Workers with Serverless. diff --git a/docs/providers/cloudflare-workers/guide/quick-start.md b/docs/providers/cloudflare-workers/guide/quick-start.md index f382901ee2a..7d3cead2afc 100644 --- a/docs/providers/cloudflare-workers/guide/quick-start.md +++ b/docs/providers/cloudflare-workers/guide/quick-start.md @@ -14,7 +14,7 @@ layout: Doc ## Pre-requisites Node.js `v6.5.0` or later. -Serverless CLI `v1.31` or later. You can run `npm install -g serverless` to install it. +Serverless CLI `v1.31.0` or later. You can run `npm install -g serverless` to install it. ## Create a new service Create a new service using either the `cloudflare-workers` or `cloudflare-workers-enterprise` template, depending on your Cloudflare domain’s plan level, and specifying a unique name and an optional path for your service. From 0ec216ac2d51efa030110d5c859d361275a66d9f Mon Sep 17 00:00:00 2001 From: Stephen Pinkerton Date: Tue, 11 Sep 2018 00:02:04 -0700 Subject: [PATCH 10/18] Add note about updated route handling --- docs/providers/cloudflare-workers/guide/deploying.md | 6 ++++-- docs/providers/cloudflare-workers/guide/intro.md | 2 +- docs/providers/cloudflare-workers/guide/quick-start.md | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/providers/cloudflare-workers/guide/deploying.md b/docs/providers/cloudflare-workers/guide/deploying.md index f92ac7572da..271399b44dd 100644 --- a/docs/providers/cloudflare-workers/guide/deploying.md +++ b/docs/providers/cloudflare-workers/guide/deploying.md @@ -44,12 +44,12 @@ This is the main method for doing deployments with the Serverless Framework: serverless deploy ``` -Use this method when you have updated your Function, Event or Resource configuration in `serverless.yml` and you want to deploy that change (or multiple changes at the same time) to your Cloudflare Worker. +Use this method when you have updated your Function, Event or Resource configuration in `serverless.yml` and you want to deploy that change (or multiple changes at the same time) to your Cloudflare Worker. If you've made changes to any of your routes since last deploying, the Serverless Framework will update them on the server for you. ### How It Works The Serverless Framework reads in `serverless.yml` and uses it to provision your Functions. -For each defined function in your `serverless.yml` file, the Framework will create a Cloudflare Workers script. +For each defined Function in your `serverless.yml` file, the Framework will create a Cloudflare Workers script. This means that only enterprise customers can declare more than one Function, but anyone can use [webpack](https://developers.cloudflare.com/workers/writing-workers/using-npm-modules/) to package their application into a single script. For example, let's take the following example `serverless.yml` file: @@ -109,5 +109,7 @@ This deployment method updates or deploys a single function. It performs the pla serverless deploy --function myFunction ``` +If you've made changes to the routes corresponding to this Function since last deploying, the Serverless Framework will update them on the server for you. + ### Tips Check out the [deploy command docs](../cli-reference/deploy.md) for all details and options. diff --git a/docs/providers/cloudflare-workers/guide/intro.md b/docs/providers/cloudflare-workers/guide/intro.md index f238916f38e..9e13c3ac480 100644 --- a/docs/providers/cloudflare-workers/guide/intro.md +++ b/docs/providers/cloudflare-workers/guide/intro.md @@ -13,7 +13,7 @@ layout: Doc # Cloudflare Workers - Introduction -The Serverless Framework helps you develop and deploy serverless applications using Cloudflare Workers. It's a CLI that offers structure, automation, and best practices out-of-the-box, allowing you to focus on building sophisticated, event-driven, serverless architectures, comprised of [Functions](#functions) and [Events](#events). +The Serverless Framework helps you develop and deploy serverless applications using Cloudflare Workers. It's a CLI that offers structure, automation, and best practices out-of-the-box, allowing you to focus on building sophisticated, event-driven, serverless architectures, comprised of [Functions](#functions) and [Events](#events). It lets you manage your Worker routing in a flat configuration file that you can keep in alongside the rest of your code in version control, and the Serverless Framework will intelligently manage your routes as they change. The Serverless Framework is different than other application frameworks because: * It manages your code as well as your infrastructure diff --git a/docs/providers/cloudflare-workers/guide/quick-start.md b/docs/providers/cloudflare-workers/guide/quick-start.md index 7d3cead2afc..b32a5945a29 100644 --- a/docs/providers/cloudflare-workers/guide/quick-start.md +++ b/docs/providers/cloudflare-workers/guide/quick-start.md @@ -56,13 +56,13 @@ You’ll need to redefine your environmental variables after each time you close 1. **Deploy the Service** -Use this when you have made changes to your Functions, Events or Resources in `serverless.yml` or you simply want to deploy all changes within your Service at the same time. +Use this when you have made changes to your Functions, Events or Resources in `serverless.yml` or you simply want to deploy all changes within your Service at the same time. If you've made changes to your routes since last deploying, the Serverless Framework will update them on the server for you. ```bash serverless deploy ``` -2. **Deploy the Function** +1. **Deploy the Function** Use this to quickly upload and overwrite your function code, allowing you to develop faster. From c94db19d0b2b8aa28260b55c400d5622b5c4fec6 Mon Sep 17 00:00:00 2001 From: Stephen Pinkerton Date: Tue, 11 Sep 2018 00:05:00 -0700 Subject: [PATCH 11/18] Add links to Workers page --- docs/providers/cloudflare-workers/guide/intro.md | 2 +- docs/providers/cloudflare-workers/guide/quick-start.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/providers/cloudflare-workers/guide/intro.md b/docs/providers/cloudflare-workers/guide/intro.md index 9e13c3ac480..7eaf67ea5da 100644 --- a/docs/providers/cloudflare-workers/guide/intro.md +++ b/docs/providers/cloudflare-workers/guide/intro.md @@ -13,7 +13,7 @@ layout: Doc # Cloudflare Workers - Introduction -The Serverless Framework helps you develop and deploy serverless applications using Cloudflare Workers. It's a CLI that offers structure, automation, and best practices out-of-the-box, allowing you to focus on building sophisticated, event-driven, serverless architectures, comprised of [Functions](#functions) and [Events](#events). It lets you manage your Worker routing in a flat configuration file that you can keep in alongside the rest of your code in version control, and the Serverless Framework will intelligently manage your routes as they change. +The Serverless Framework helps you develop and deploy serverless applications using [Cloudflare Workers](https://www.cloudflare.com/products/cloudflare-workers/). It's a CLI that offers structure, automation, and best practices out-of-the-box, allowing you to focus on building sophisticated, event-driven, serverless architectures, comprised of [Functions](#functions) and [Events](#events). It lets you manage your Worker routing in a flat configuration file that you can keep in alongside the rest of your code in version control, and the Serverless Framework will intelligently manage your routes as they change. The Serverless Framework is different than other application frameworks because: * It manages your code as well as your infrastructure diff --git a/docs/providers/cloudflare-workers/guide/quick-start.md b/docs/providers/cloudflare-workers/guide/quick-start.md index b32a5945a29..748218147d8 100644 --- a/docs/providers/cloudflare-workers/guide/quick-start.md +++ b/docs/providers/cloudflare-workers/guide/quick-start.md @@ -28,7 +28,7 @@ $ cd new-project $ npm install ``` -Note: there are two templates for Cloudflare Workers: `cloudflare-workers` and `cloudflare-workers-enterprise`. The enterprise template sets up a project that can natively deploy [multiple scripts](https://developers.cloudflare.com/workers/api/config-api-for-enterprise/), each with their own routes. It requires an enterprise Cloudflare account to use. +Note: there are two templates for [Cloudflare Workers](https://www.cloudflare.com/products/cloudflare-workers/): `cloudflare-workers` and `cloudflare-workers-enterprise`. The enterprise template sets up a project that can natively deploy [multiple scripts](https://developers.cloudflare.com/workers/api/config-api-for-enterprise/), each with their own routes. It requires an enterprise Cloudflare account to use. The `cloudflare-workers` template still supports [conditional routing](https://developers.cloudflare.com/workers/recipes/conditional-routing/) and multiple scripts if you use a tool like [webpack](https://developers.cloudflare.com/workers/writing-workers/using-npm-modules/). From 0abdf190aaf9e0c6385a476db444b68bc93a2bad Mon Sep 17 00:00:00 2001 From: Stephen Pinkerton Date: Tue, 11 Sep 2018 00:10:35 -0700 Subject: [PATCH 12/18] Add image headers to docs --- docs/providers/cloudflare-workers/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/providers/cloudflare-workers/README.md b/docs/providers/cloudflare-workers/README.md index bc7bb23771b..5cdc8327304 100644 --- a/docs/providers/cloudflare-workers/README.md +++ b/docs/providers/cloudflare-workers/README.md @@ -18,7 +18,7 @@ If you have any questions, [search the forums](https://forum.serverless.com?utm_
@@ -39,7 +39,7 @@ If you have any questions, [search the forums](https://forum.serverless.com?utm_
@@ -59,7 +59,7 @@ If you have any questions, [search the forums](https://forum.serverless.com?utm_
From 30db8e9bd15259be8873637c917bacc444eb4c05 Mon Sep 17 00:00:00 2001 From: Stephen Pinkerton Date: Tue, 11 Sep 2018 00:15:32 -0700 Subject: [PATCH 13/18] Add to providers page --- docs/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/README.md b/docs/README.md index 3189bfba559..46abb380689 100644 --- a/docs/README.md +++ b/docs/README.md @@ -157,4 +157,19 @@ Already using AWS or another cloud provider? Read on.
+
From 4bbdacd5a9281e4cd70378de11e1944364f7ca9c Mon Sep 17 00:00:00 2001 From: Stephen Pinkerton Date: Tue, 11 Sep 2018 00:19:48 -0700 Subject: [PATCH 14/18] Change path from cloudflare-workers to cloudflare --- docs/README.md | 10 +++++----- .../{cloudflare-workers => cloudflare}/README.md | 0 .../cli-reference/README.md | 2 +- .../cli-reference/create.md | 2 +- .../cli-reference/deploy.md | 2 +- .../cli-reference/invoke.md | 0 .../cli-reference/plugin-install.md | 2 +- .../cli-reference/plugin-list.md | 2 +- .../cli-reference/plugin-search.md | 2 +- .../cli-reference/plugin-uninstall.md | 2 +- .../cli-reference/remove.md | 2 +- .../events/README.md | 2 +- .../{cloudflare-workers => cloudflare}/events/http.md | 2 +- .../{cloudflare-workers => cloudflare}/guide/README.md | 2 +- .../guide/debugging.md | 2 +- .../guide/deploying.md | 2 +- .../{cloudflare-workers => cloudflare}/guide/events.md | 2 +- .../guide/functions.md | 2 +- .../guide/installation.md | 2 +- .../{cloudflare-workers => cloudflare}/guide/intro.md | 2 +- .../guide/quick-start.md | 2 +- .../guide/services.md | 2 +- .../guide/workflow.md | 2 +- 23 files changed, 25 insertions(+), 25 deletions(-) rename docs/providers/{cloudflare-workers => cloudflare}/README.md (100%) rename docs/providers/{cloudflare-workers => cloudflare}/cli-reference/README.md (88%) rename docs/providers/{cloudflare-workers => cloudflare}/cli-reference/create.md (97%) rename docs/providers/{cloudflare-workers => cloudflare}/cli-reference/deploy.md (96%) rename docs/providers/{cloudflare-workers => cloudflare}/cli-reference/invoke.md (100%) rename docs/providers/{cloudflare-workers => cloudflare}/cli-reference/plugin-install.md (92%) rename docs/providers/{cloudflare-workers => cloudflare}/cli-reference/plugin-list.md (87%) rename docs/providers/{cloudflare-workers => cloudflare}/cli-reference/plugin-search.md (90%) rename docs/providers/{cloudflare-workers => cloudflare}/cli-reference/plugin-uninstall.md (89%) rename docs/providers/{cloudflare-workers => cloudflare}/cli-reference/remove.md (89%) rename docs/providers/{cloudflare-workers => cloudflare}/events/README.md (89%) rename docs/providers/{cloudflare-workers => cloudflare}/events/http.md (95%) rename docs/providers/{cloudflare-workers => cloudflare}/guide/README.md (89%) rename docs/providers/{cloudflare-workers => cloudflare}/guide/debugging.md (96%) rename docs/providers/{cloudflare-workers => cloudflare}/guide/deploying.md (98%) rename docs/providers/{cloudflare-workers => cloudflare}/guide/events.md (95%) rename docs/providers/{cloudflare-workers => cloudflare}/guide/functions.md (97%) rename docs/providers/{cloudflare-workers => cloudflare}/guide/installation.md (96%) rename docs/providers/{cloudflare-workers => cloudflare}/guide/intro.md (98%) rename docs/providers/{cloudflare-workers => cloudflare}/guide/quick-start.md (98%) rename docs/providers/{cloudflare-workers => cloudflare}/guide/services.md (99%) rename docs/providers/{cloudflare-workers => cloudflare}/guide/workflow.md (96%) diff --git a/docs/README.md b/docs/README.md index 46abb380689..5b8551ba2e5 100644 --- a/docs/README.md +++ b/docs/README.md @@ -159,16 +159,16 @@ Already using AWS or another cloud provider? Read on.
diff --git a/docs/providers/cloudflare-workers/README.md b/docs/providers/cloudflare/README.md similarity index 100% rename from docs/providers/cloudflare-workers/README.md rename to docs/providers/cloudflare/README.md diff --git a/docs/providers/cloudflare-workers/cli-reference/README.md b/docs/providers/cloudflare/cli-reference/README.md similarity index 88% rename from docs/providers/cloudflare-workers/cli-reference/README.md rename to docs/providers/cloudflare/cli-reference/README.md index e600d5ae0db..5e37d803895 100644 --- a/docs/providers/cloudflare-workers/cli-reference/README.md +++ b/docs/providers/cloudflare/cli-reference/README.md @@ -5,7 +5,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/cli-reference/) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/cli-reference/) # Serverless Cloudflare Workers CLI Reference diff --git a/docs/providers/cloudflare-workers/cli-reference/create.md b/docs/providers/cloudflare/cli-reference/create.md similarity index 97% rename from docs/providers/cloudflare-workers/cli-reference/create.md rename to docs/providers/cloudflare/cli-reference/create.md index 51f2d12affa..e5ce773dbec 100644 --- a/docs/providers/cloudflare-workers/cli-reference/create.md +++ b/docs/providers/cloudflare/cli-reference/create.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/cli-reference/create) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/cli-reference/create) diff --git a/docs/providers/cloudflare-workers/cli-reference/deploy.md b/docs/providers/cloudflare/cli-reference/deploy.md similarity index 96% rename from docs/providers/cloudflare-workers/cli-reference/deploy.md rename to docs/providers/cloudflare/cli-reference/deploy.md index d2040a7d071..6e9c3e5fbe4 100644 --- a/docs/providers/cloudflare-workers/cli-reference/deploy.md +++ b/docs/providers/cloudflare/cli-reference/deploy.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/cli-reference/deploy) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/cli-reference/deploy) diff --git a/docs/providers/cloudflare-workers/cli-reference/invoke.md b/docs/providers/cloudflare/cli-reference/invoke.md similarity index 100% rename from docs/providers/cloudflare-workers/cli-reference/invoke.md rename to docs/providers/cloudflare/cli-reference/invoke.md diff --git a/docs/providers/cloudflare-workers/cli-reference/plugin-install.md b/docs/providers/cloudflare/cli-reference/plugin-install.md similarity index 92% rename from docs/providers/cloudflare-workers/cli-reference/plugin-install.md rename to docs/providers/cloudflare/cli-reference/plugin-install.md index 45040c4d44a..0bb19f137f1 100644 --- a/docs/providers/cloudflare-workers/cli-reference/plugin-install.md +++ b/docs/providers/cloudflare/cli-reference/plugin-install.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/cli-reference/plugin-install) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/cli-reference/plugin-install) # Plugin Install diff --git a/docs/providers/cloudflare-workers/cli-reference/plugin-list.md b/docs/providers/cloudflare/cli-reference/plugin-list.md similarity index 87% rename from docs/providers/cloudflare-workers/cli-reference/plugin-list.md rename to docs/providers/cloudflare/cli-reference/plugin-list.md index c4a12ff1ef4..c7b74d80407 100644 --- a/docs/providers/cloudflare-workers/cli-reference/plugin-list.md +++ b/docs/providers/cloudflare/cli-reference/plugin-list.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/cli-reference/plugin-list) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/cli-reference/plugin-list) # Plugin List diff --git a/docs/providers/cloudflare-workers/cli-reference/plugin-search.md b/docs/providers/cloudflare/cli-reference/plugin-search.md similarity index 90% rename from docs/providers/cloudflare-workers/cli-reference/plugin-search.md rename to docs/providers/cloudflare/cli-reference/plugin-search.md index 3500b660f85..4f793f03511 100644 --- a/docs/providers/cloudflare-workers/cli-reference/plugin-search.md +++ b/docs/providers/cloudflare/cli-reference/plugin-search.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/cli-reference/plugin-search) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/cli-reference/plugin-search) # Plugin Search diff --git a/docs/providers/cloudflare-workers/cli-reference/plugin-uninstall.md b/docs/providers/cloudflare/cli-reference/plugin-uninstall.md similarity index 89% rename from docs/providers/cloudflare-workers/cli-reference/plugin-uninstall.md rename to docs/providers/cloudflare/cli-reference/plugin-uninstall.md index b7257ecbe89..74852fb6b6f 100644 --- a/docs/providers/cloudflare-workers/cli-reference/plugin-uninstall.md +++ b/docs/providers/cloudflare/cli-reference/plugin-uninstall.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/cli-reference/plugin-uninstall) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/cli-reference/plugin-uninstall) # Plugin Uninstall diff --git a/docs/providers/cloudflare-workers/cli-reference/remove.md b/docs/providers/cloudflare/cli-reference/remove.md similarity index 89% rename from docs/providers/cloudflare-workers/cli-reference/remove.md rename to docs/providers/cloudflare/cli-reference/remove.md index 2dcfaa6e5a4..505bc0df19a 100644 --- a/docs/providers/cloudflare-workers/cli-reference/remove.md +++ b/docs/providers/cloudflare/cli-reference/remove.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/cli-reference/remove) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/cli-reference/remove) # Cloudflare Workers - Remove diff --git a/docs/providers/cloudflare-workers/events/README.md b/docs/providers/cloudflare/events/README.md similarity index 89% rename from docs/providers/cloudflare-workers/events/README.md rename to docs/providers/cloudflare/events/README.md index 171c7a2f811..09b25c7a898 100644 --- a/docs/providers/cloudflare-workers/events/README.md +++ b/docs/providers/cloudflare/events/README.md @@ -5,7 +5,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/events/) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/events/) # Serverless Cloudflare Workers Events diff --git a/docs/providers/cloudflare-workers/events/http.md b/docs/providers/cloudflare/events/http.md similarity index 95% rename from docs/providers/cloudflare-workers/events/http.md rename to docs/providers/cloudflare/events/http.md index 4b5c5fc541e..0713feeae53 100644 --- a/docs/providers/cloudflare-workers/events/http.md +++ b/docs/providers/cloudflare/events/http.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/events/http) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/events/http) diff --git a/docs/providers/cloudflare-workers/guide/README.md b/docs/providers/cloudflare/guide/README.md similarity index 89% rename from docs/providers/cloudflare-workers/guide/README.md rename to docs/providers/cloudflare/guide/README.md index be51a83a8c9..bf10653c8fd 100644 --- a/docs/providers/cloudflare-workers/guide/README.md +++ b/docs/providers/cloudflare/guide/README.md @@ -5,7 +5,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/guide/) # Serverless Cloudflare Workers Guide diff --git a/docs/providers/cloudflare-workers/guide/debugging.md b/docs/providers/cloudflare/guide/debugging.md similarity index 96% rename from docs/providers/cloudflare-workers/guide/debugging.md rename to docs/providers/cloudflare/guide/debugging.md index 76d6f9fbd76..d696b1932ab 100644 --- a/docs/providers/cloudflare-workers/guide/debugging.md +++ b/docs/providers/cloudflare/guide/debugging.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/debugging) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/guide/debugging) # Cloudflare Workers - Debugging diff --git a/docs/providers/cloudflare-workers/guide/deploying.md b/docs/providers/cloudflare/guide/deploying.md similarity index 98% rename from docs/providers/cloudflare-workers/guide/deploying.md rename to docs/providers/cloudflare/guide/deploying.md index 271399b44dd..74f8632d7bb 100644 --- a/docs/providers/cloudflare-workers/guide/deploying.md +++ b/docs/providers/cloudflare/guide/deploying.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/deploying) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/guide/deploying) # Cloudflare Workers - Deploying diff --git a/docs/providers/cloudflare-workers/guide/events.md b/docs/providers/cloudflare/guide/events.md similarity index 95% rename from docs/providers/cloudflare-workers/guide/events.md rename to docs/providers/cloudflare/guide/events.md index 1b6e636be30..fb1228b6e80 100644 --- a/docs/providers/cloudflare-workers/guide/events.md +++ b/docs/providers/cloudflare/guide/events.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/events) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/guide/events) diff --git a/docs/providers/cloudflare-workers/guide/functions.md b/docs/providers/cloudflare/guide/functions.md similarity index 97% rename from docs/providers/cloudflare-workers/guide/functions.md rename to docs/providers/cloudflare/guide/functions.md index 340e24ad4f0..ab114991fea 100644 --- a/docs/providers/cloudflare-workers/guide/functions.md +++ b/docs/providers/cloudflare/guide/functions.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/functions) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/guide/functions) # Cloudflare Workers - Functions diff --git a/docs/providers/cloudflare-workers/guide/installation.md b/docs/providers/cloudflare/guide/installation.md similarity index 96% rename from docs/providers/cloudflare-workers/guide/installation.md rename to docs/providers/cloudflare/guide/installation.md index b2f8f312b84..1771fcf70b1 100644 --- a/docs/providers/cloudflare-workers/guide/installation.md +++ b/docs/providers/cloudflare/guide/installation.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/installation) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/guide/installation) # Cloudflare Workers - Installation diff --git a/docs/providers/cloudflare-workers/guide/intro.md b/docs/providers/cloudflare/guide/intro.md similarity index 98% rename from docs/providers/cloudflare-workers/guide/intro.md rename to docs/providers/cloudflare/guide/intro.md index 7eaf67ea5da..32267c54b88 100644 --- a/docs/providers/cloudflare-workers/guide/intro.md +++ b/docs/providers/cloudflare/guide/intro.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/intro) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/guide/intro) diff --git a/docs/providers/cloudflare-workers/guide/quick-start.md b/docs/providers/cloudflare/guide/quick-start.md similarity index 98% rename from docs/providers/cloudflare-workers/guide/quick-start.md rename to docs/providers/cloudflare/guide/quick-start.md index 748218147d8..c56c1311e46 100644 --- a/docs/providers/cloudflare-workers/guide/quick-start.md +++ b/docs/providers/cloudflare/guide/quick-start.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/quick-start) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/guide/quick-start) # Cloudflare Workers - Quickstart diff --git a/docs/providers/cloudflare-workers/guide/services.md b/docs/providers/cloudflare/guide/services.md similarity index 99% rename from docs/providers/cloudflare-workers/guide/services.md rename to docs/providers/cloudflare/guide/services.md index f1b45a6e7c1..fdd2be9dae0 100644 --- a/docs/providers/cloudflare-workers/guide/services.md +++ b/docs/providers/cloudflare/guide/services.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/services) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/guide/services) # Cloudflare Workers - Services diff --git a/docs/providers/cloudflare-workers/guide/workflow.md b/docs/providers/cloudflare/guide/workflow.md similarity index 96% rename from docs/providers/cloudflare-workers/guide/workflow.md rename to docs/providers/cloudflare/guide/workflow.md index 2b5fe37a78e..c6dda1f8d74 100644 --- a/docs/providers/cloudflare-workers/guide/workflow.md +++ b/docs/providers/cloudflare/guide/workflow.md @@ -7,7 +7,7 @@ layout: Doc --> -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare-workers/guide/workflow) +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/cloudflare/guide/workflow) From 1e37c2c7dc826b5d5d2b2c251248c2bd64cdab32 Mon Sep 17 00:00:00 2001 From: Stephen Pinkerton Date: Tue, 11 Sep 2018 00:23:15 -0700 Subject: [PATCH 15/18] Add docs link to menu --- docs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/README.md b/docs/README.md index 5b8551ba2e5..8b736e1a8ab 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,6 +13,7 @@ menuItems: - {menuText: "- Kubeless" , path: /framework/docs/providers/kubeless/} - {menuText: "- Spotinst" , path: /framework/docs/providers/spotinst/} - {menuText: "- Webtasks" , path: /framework/docs/providers/webtasks/} + - {menuText: "- Cloudflare" , path: /framework/docs/providers/cloudflare/} --> From 8c5511cecc9c84b471b9028323b6f509d1d580c3 Mon Sep 17 00:00:00 2001 From: Stephen Pinkerton Date: Tue, 11 Sep 2018 00:40:24 -0700 Subject: [PATCH 16/18] Update PoP number --- docs/providers/cloudflare/guide/intro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/providers/cloudflare/guide/intro.md b/docs/providers/cloudflare/guide/intro.md index 32267c54b88..42c1c9bcd58 100644 --- a/docs/providers/cloudflare/guide/intro.md +++ b/docs/providers/cloudflare/guide/intro.md @@ -23,7 +23,7 @@ The Serverless Framework is different than other application frameworks because: Here are the Serverless Framework's main concepts and how they pertain to Cloudflare Workers. ### Functions -A Function is a Cloudflare Worker. It's an independent unit of deployment, like a microservice. It's merely code, deployed on Cloudflare’s 151+ PoPs (points of presence), that is most often written to perform a single job, such as: +A Function is a Cloudflare Worker. It's an independent unit of deployment, like a microservice. It's merely code, deployed on Cloudflare’s 152+ PoPs (points of presence), that is most often written to perform a single job, such as: * *Performing A/B Testing* * *Custom routing based on user location, custom headers, etc.* * *Hosting webhook endpoints* From e2050f993d1bb2767cbc36d2d7b88e79743e83e5 Mon Sep 17 00:00:00 2001 From: Raees Date: Tue, 11 Sep 2018 19:13:17 +0500 Subject: [PATCH 17/18] Fix serverless-cloudflare-workers version in enterprise --- .../create/templates/cloudflare-workers-enterprise/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/create/templates/cloudflare-workers-enterprise/package.json b/lib/plugins/create/templates/cloudflare-workers-enterprise/package.json index 8d235eef79e..6bd04587438 100644 --- a/lib/plugins/create/templates/cloudflare-workers-enterprise/package.json +++ b/lib/plugins/create/templates/cloudflare-workers-enterprise/package.json @@ -9,6 +9,6 @@ "author": "cloudflare", "license": "MIT", "devDependencies": { - "serverless-cloudflare-workers": "1.0.0" + "serverless-cloudflare-workers": "0.1.0" } } From 7616fb2a825b39a5a2d4991ad0e40665a99f279f Mon Sep 17 00:00:00 2001 From: Raees Date: Tue, 11 Sep 2018 19:13:34 +0500 Subject: [PATCH 18/18] Fix serverless-cloudflare-workers version --- lib/plugins/create/templates/cloudflare-workers/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/create/templates/cloudflare-workers/package.json b/lib/plugins/create/templates/cloudflare-workers/package.json index 93082d881a7..1ea66bea77b 100644 --- a/lib/plugins/create/templates/cloudflare-workers/package.json +++ b/lib/plugins/create/templates/cloudflare-workers/package.json @@ -9,6 +9,6 @@ "author": "cloudflare", "license": "MIT", "devDependencies": { - "serverless-cloudflare-workers": "1.0.0" + "serverless-cloudflare-workers": "0.1.0" } }