diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..109ea4e --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +/target +/dist +**/*.rs.bk +Cargo.lock +bin/ +pkg/ +wasm-pack.log +worker/ +node_modules/ +.cargo-ok diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..a06a385 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "singleQuote": true, + "semi": false, + "trailingComma": "all", + "tabWidth": 2, + "printWidth": 80 +} diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..4d4ce9f --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,25 @@ +Copyright (c) 2020 Ivan Chernov + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..439a394 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# 👷 `worker-template` Hello World + +A template for kick starting a Cloudflare worker project. + +[`index.js`](https://github.com/cloudflare/worker-template/blob/master/index.js) is the content of the Workers script. + +#### Wrangler + +To generate using [wrangler](https://github.com/cloudflare/wrangler) + +``` +wrangler generate projectname https://github.com/cloudflare/worker-template +``` + +#### Serverless + +To deploy using serverless add a [`serverless.yml`](https://serverless.com/framework/docs/providers/cloudflare/) file. diff --git a/index.js b/index.js new file mode 100644 index 0000000..5650a22 --- /dev/null +++ b/index.js @@ -0,0 +1,12 @@ +addEventListener('fetch', event => { + event.respondWith(handleRequest(event.request)) +}) +/** + * Respond with hello worker text + * @param {Request} request + */ +async function handleRequest(request) { + return new Response('Hello worker!', { + headers: { 'content-type': 'text/plain' }, + }) +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..9fc1819 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "private": true, + "name": "cf-metrics", + "version": "1.0.0", + "description": "A template for kick starting a Cloudflare Workers project", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "format": "prettier --write '**/*.{js,css,json,md}'" + }, + "author": "vanadium23 ", + "license": "MIT", + "devDependencies": { + "prettier": "^1.18.2" + } +} diff --git a/wrangler.toml b/wrangler.toml new file mode 100644 index 0000000..40b2408 --- /dev/null +++ b/wrangler.toml @@ -0,0 +1,7 @@ +name = "cf-metrics" +type = "javascript" + +account_id = "" +workers_dev = true +route = "" +zone_id = "" \ No newline at end of file