diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000000000..2e7aed6303240db --- /dev/null +++ b/.gitattributes @@ -0,0 +1,30 @@ +* text=auto +* text eol=lf + +# (binary is a macro for -text -diff) +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.avif binary +*.webp binary +*.jxl binary +*.ico binary +*.mov binary +*.mp4 binary +*.mp3 binary +*.flv binary +*.fla binary +*.swf binary +*.gz binary +*.zip binary +*.7z binary +*.ttf binary +*.eot binary +*.woff binary +*.woff2 binary +*.pyc binary +*.pdf binary +*.ez binary +*.bz2 binary +*.swp binary \ No newline at end of file diff --git a/content/r2/api/s3/presigned-urls.md b/content/r2/api/s3/presigned-urls.md index 4842bad416b7561..16b93fa56874338 100644 --- a/content/r2/api/s3/presigned-urls.md +++ b/content/r2/api/s3/presigned-urls.md @@ -87,7 +87,7 @@ const r2 = new AwsClient({ }); export default { - async fetch(req: Request) { + async fetch(req: Request): Promise { // This is just an example to demonstrating using aws4fetch to generate a presigned URL. // This Worker should not be used as-is as it does not authenticate the request, meaning // that anyone can upload to your bucket. diff --git a/content/workers/examples/103-early-hints.md b/content/workers/examples/103-early-hints.md index 2cb1852b335e1b7..e4f9359bb6788e7 100644 --- a/content/workers/examples/103-early-hints.md +++ b/content/workers/examples/103-early-hints.md @@ -87,7 +87,7 @@ const HTML = ` `; export default { - async fetch(req: Request) { + async fetch(req: Request): Promise { // If request is for test.css, serve the raw CSS if (/test\.css$/.test(req.url)) { return new Response(CSS, { diff --git a/content/workers/examples/ab-testing.md b/content/workers/examples/ab-testing.md index 3b3af2e02014b68..c9ad493d7262a1f 100644 --- a/content/workers/examples/ab-testing.md +++ b/content/workers/examples/ab-testing.md @@ -59,7 +59,7 @@ export default { const NAME = "myExampleWorkersABTest"; export default { - async fetch(req: Request) { + async fetch(req: Request): Promise { const url = new URL(req.url); // Enable Passthrough to allow direct access to control and test routes. if (url.pathname.startsWith("/control") || url.pathname.startsWith("/test")) diff --git a/content/workers/examples/accessing-the-cloudflare-object.md b/content/workers/examples/accessing-the-cloudflare-object.md index 414d960c3b634e2..8c12a573b8c24a2 100644 --- a/content/workers/examples/accessing-the-cloudflare-object.md +++ b/content/workers/examples/accessing-the-cloudflare-object.md @@ -39,7 +39,7 @@ export default { ```ts export default { - async fetch(req: Request) { + async fetch(req: Request): Promise { const data = req.cf !== undefined ? req.cf diff --git a/content/workers/examples/aggregate-requests.md b/content/workers/examples/aggregate-requests.md index 624e260523407a9..79507f0232d91ec 100644 --- a/content/workers/examples/aggregate-requests.md +++ b/content/workers/examples/aggregate-requests.md @@ -66,7 +66,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { /** * someHost is set up to return JSON responses * Replace url1 and url2 with the hosts you wish to send requests to diff --git a/content/workers/examples/alter-headers.md b/content/workers/examples/alter-headers.md index 73fac091c099ab5..70ec9f05d8e4851 100644 --- a/content/workers/examples/alter-headers.md +++ b/content/workers/examples/alter-headers.md @@ -48,7 +48,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { const response = await fetch(request); // Clone the response so that it's no longer immutable diff --git a/content/workers/examples/auth-with-headers.md b/content/workers/examples/auth-with-headers.md index 00a2e9fa49715a9..0699de2f999044c 100644 --- a/content/workers/examples/auth-with-headers.md +++ b/content/workers/examples/auth-with-headers.md @@ -51,7 +51,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { /** * @param {string} PRESHARED_AUTH_HEADER_KEY Custom header to check for key * @param {string} PRESHARED_AUTH_HEADER_VALUE Hard coded key value diff --git a/content/workers/examples/basic-auth.md b/content/workers/examples/basic-auth.md index d401d1dd371184c..a366d820681acee 100644 --- a/content/workers/examples/basic-auth.md +++ b/content/workers/examples/basic-auth.md @@ -177,7 +177,7 @@ function timingSafeEqual(a: string, b: string) { } export default { - async fetch(request: Request, env: { PASSWORD: string }) { + async fetch(request: Request, env: { PASSWORD: string }): Promise { const BASIC_USER = "admin"; // You will need an admin password. This should be diff --git a/content/workers/examples/block-on-tls.md b/content/workers/examples/block-on-tls.md index e6879165d66e2eb..c0d450b01814f66 100644 --- a/content/workers/examples/block-on-tls.md +++ b/content/workers/examples/block-on-tls.md @@ -42,7 +42,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { try { const tlsVersion = request.cf.tlsVersion; // Allow only TLS versions 1.2 and 1.3 diff --git a/content/workers/examples/bulk-origin-proxy.md b/content/workers/examples/bulk-origin-proxy.md index 7d9c04157ff6061..db00603f260e504 100644 --- a/content/workers/examples/bulk-origin-proxy.md +++ b/content/workers/examples/bulk-origin-proxy.md @@ -44,7 +44,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { /** * An object with different URLs to fetch * @param {Object} ORIGINS diff --git a/content/workers/examples/bulk-redirects.md b/content/workers/examples/bulk-redirects.md index b1967205547a905..7d4a78e7678ffe6 100644 --- a/content/workers/examples/bulk-redirects.md +++ b/content/workers/examples/bulk-redirects.md @@ -43,7 +43,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { const externalHostname = "examples.cloudflareworkers.com"; const redirectMap = new Map([ diff --git a/content/workers/examples/cache-api.md b/content/workers/examples/cache-api.md index 9888195dd2d4374..b5b5dae1ca95fbd 100644 --- a/content/workers/examples/cache-api.md +++ b/content/workers/examples/cache-api.md @@ -57,7 +57,7 @@ export default { ```ts export default { - async fetch(request: Request, env: unknown, ctx: ExecutionContext) { + async fetch(request: Request, env: unknown, ctx: ExecutionContext): Promise { const cacheUrl = new URL(request.url); // Construct the cache key from the cache URL diff --git a/content/workers/examples/cache-post-request.md b/content/workers/examples/cache-post-request.md index d1552e947ed48e1..3682de2de1c057e 100644 --- a/content/workers/examples/cache-post-request.md +++ b/content/workers/examples/cache-post-request.md @@ -64,7 +64,7 @@ export default { ```ts export default { - async fetch(request: Request, env: unknown, ctx: ExecutionContext) { + async fetch(request: Request, env: unknown, ctx: ExecutionContext): Promise { async function sha256(message) { // encode as UTF-8 const msgBuffer = await new TextEncoder().encode(message); diff --git a/content/workers/examples/cache-tags.md b/content/workers/examples/cache-tags.md index a7ee5613d19e278..ebef0ef38b82b8d 100644 --- a/content/workers/examples/cache-tags.md +++ b/content/workers/examples/cache-tags.md @@ -60,7 +60,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { const requestUrl = new URL(request.url); const params = requestUrl.searchParams; const tags = diff --git a/content/workers/examples/cache-using-fetch.md b/content/workers/examples/cache-using-fetch.md index c4937d06ff902f4..c7d5e523793fd39 100644 --- a/content/workers/examples/cache-using-fetch.md +++ b/content/workers/examples/cache-using-fetch.md @@ -130,7 +130,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { let url = new URL(request.url); if (Math.random() < 0.5) { diff --git a/content/workers/examples/conditional-response.md b/content/workers/examples/conditional-response.md index 98d0e6b04c13967..c8ed64d262eea04 100644 --- a/content/workers/examples/conditional-response.md +++ b/content/workers/examples/conditional-response.md @@ -65,7 +65,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { const BLOCKED_HOSTNAMES = ["nope.mywebsite.com", "bye.website.com"]; // Return a new Response based on a URL's hostname const url = new URL(request.url); diff --git a/content/workers/examples/cors-header-proxy.md b/content/workers/examples/cors-header-proxy.md index b18f70b94c87791..726167a3368ae9f 100644 --- a/content/workers/examples/cors-header-proxy.md +++ b/content/workers/examples/cors-header-proxy.md @@ -171,7 +171,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { const corsHeaders = { "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET,HEAD,POST,OPTIONS", diff --git a/content/workers/examples/country-code-redirect.md b/content/workers/examples/country-code-redirect.md index 7cf0d1373b11dd7..46473664422b32d 100644 --- a/content/workers/examples/country-code-redirect.md +++ b/content/workers/examples/country-code-redirect.md @@ -48,7 +48,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { /** * A map of the URLs to redirect to * @param {Object} countryMap diff --git a/content/workers/examples/data-loss-prevention.md b/content/workers/examples/data-loss-prevention.md index 8a09d1f6fd98b9e..b2688bdebd87ed0 100644 --- a/content/workers/examples/data-loss-prevention.md +++ b/content/workers/examples/data-loss-prevention.md @@ -89,7 +89,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { const DEBUG = true; const SOME_HOOK_SERVER = "https://webhook.flow-wolf.io/hook"; diff --git a/content/workers/examples/debugging-logs.md b/content/workers/examples/debugging-logs.md index a31ebc11c1a6fd8..7b2fdee267538e7 100644 --- a/content/workers/examples/debugging-logs.md +++ b/content/workers/examples/debugging-logs.md @@ -61,7 +61,7 @@ export default { ```ts export default { - async fetch(request: Request, env: unknown, ctx: ExecutionContext) { + async fetch(request: Request, env: unknown, ctx: ExecutionContext): Promise { // Service configured to receive logs const LOG_URL = "https://log-service.example.com/"; diff --git a/content/workers/examples/extract-cookie-value.md b/content/workers/examples/extract-cookie-value.md index 120947c8b84f844..8d3dd25d71d1c8e 100644 --- a/content/workers/examples/extract-cookie-value.md +++ b/content/workers/examples/extract-cookie-value.md @@ -35,7 +35,7 @@ export default { ```ts import { parse } from "cookie"; export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { // The name of the cookie const COOKIE_NAME = "__uid"; const cookie = parse(request.headers.get("Cookie") || ""); diff --git a/content/workers/examples/fetch-html.md b/content/workers/examples/fetch-html.md index 17a804ae3ac4274..8c411ed356e7957 100644 --- a/content/workers/examples/fetch-html.md +++ b/content/workers/examples/fetch-html.md @@ -21,7 +21,7 @@ updated: 2024-01-11 ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { /** * Replace `remote` with the host you wish to send requests to */ diff --git a/content/workers/examples/fetch-json.md b/content/workers/examples/fetch-json.md index acec926b0b76b37..12ce5a954504c8c 100644 --- a/content/workers/examples/fetch-json.md +++ b/content/workers/examples/fetch-json.md @@ -57,7 +57,7 @@ export default { ```ts export default { - async fetch(request: Request, env: unknown, ctx: ExecutionContext) { + async fetch(request: Request, env: unknown, ctx: ExecutionContext): Promise { /** * Example someHost is set up to take in a JSON request * Replace url with the host you wish to send requests to diff --git a/content/workers/examples/geolocation-app-weather.md b/content/workers/examples/geolocation-app-weather.md index db59fc9f2633c8f..80ca2b2c61bb7b5 100644 --- a/content/workers/examples/geolocation-app-weather.md +++ b/content/workers/examples/geolocation-app-weather.md @@ -68,7 +68,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { let endpoint = "https://api.waqi.info/feed/geo:"; const token = ""; //Use a token from https://aqicn.org/api/ let html_style = `body{padding:6em; font-family: sans-serif;} h1{color:#f6821f}`; diff --git a/content/workers/examples/geolocation-custom-styling.md b/content/workers/examples/geolocation-custom-styling.md index a24b87242c45019..6de3808b7254207 100644 --- a/content/workers/examples/geolocation-custom-styling.md +++ b/content/workers/examples/geolocation-custom-styling.md @@ -186,7 +186,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { let grads = [ [ { color: "00000c", position: 0 }, diff --git a/content/workers/examples/geolocation-hello-world.md b/content/workers/examples/geolocation-hello-world.md index 0a8485f837eadce..2b01218045f5949 100644 --- a/content/workers/examples/geolocation-hello-world.md +++ b/content/workers/examples/geolocation-hello-world.md @@ -60,7 +60,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { let html_content = ""; let html_style = "body{padding:6em; font-family: sans-serif;} h1{color:#f6821f;}"; diff --git a/content/workers/examples/hot-link-protection.md b/content/workers/examples/hot-link-protection.md index 8f7ee843c64e2b2..d3816fc11978d48 100644 --- a/content/workers/examples/hot-link-protection.md +++ b/content/workers/examples/hot-link-protection.md @@ -47,7 +47,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { const HOMEPAGE_URL = "https://tutorial.cloudflareworkers.com/"; const PROTECTED_TYPE = "image/"; diff --git a/content/workers/examples/images-workers.md b/content/workers/examples/images-workers.md index 1948af73bdf3d9f..63cc9242c2c9436 100644 --- a/content/workers/examples/images-workers.md +++ b/content/workers/examples/images-workers.md @@ -41,7 +41,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { // You can find this in the dashboard, it should look something like this: ZWd9g1K7eljCn_KDTu_MWA const accountHash = ""; diff --git a/content/workers/examples/logging-headers.md b/content/workers/examples/logging-headers.md index 1eca4a76127a2a7..14ab46534da2172 100644 --- a/content/workers/examples/logging-headers.md +++ b/content/workers/examples/logging-headers.md @@ -29,7 +29,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { console.log(new Map(request.headers)); return new Response("Hello world"); }, diff --git a/content/workers/examples/modify-request-property.md b/content/workers/examples/modify-request-property.md index ce30346205e3aff..26287145b5f90bd 100644 --- a/content/workers/examples/modify-request-property.md +++ b/content/workers/examples/modify-request-property.md @@ -76,7 +76,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { /** * Example someHost is set up to return raw JSON * @param {string} someUrl the URL to send the request to, since we are setting hostname too only path is applied diff --git a/content/workers/examples/modify-response.md b/content/workers/examples/modify-response.md index 082778eba361cde..c525bf42baf9f14 100644 --- a/content/workers/examples/modify-response.md +++ b/content/workers/examples/modify-response.md @@ -67,7 +67,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { /** * @param {string} headerNameSrc Header to get the new value from * @param {string} headerNameDst Header to set based off of value in src diff --git a/content/workers/examples/post-json.md b/content/workers/examples/post-json.md index 67879089d39f1a9..8b3ad7a329d61d9 100644 --- a/content/workers/examples/post-json.md +++ b/content/workers/examples/post-json.md @@ -67,7 +67,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { /** * Example someHost is set up to take in a JSON request * Replace url with the host you wish to send requests to diff --git a/content/workers/examples/read-post.md b/content/workers/examples/read-post.md index fd11c59ff335387..d334d5543c5a47e 100644 --- a/content/workers/examples/read-post.md +++ b/content/workers/examples/read-post.md @@ -77,7 +77,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { /** * rawHtmlResponse returns HTML inputted directly * into the worker script diff --git a/content/workers/examples/redirect.md b/content/workers/examples/redirect.md index fa121ea97448e96..e9e26e55495b37b 100644 --- a/content/workers/examples/redirect.md +++ b/content/workers/examples/redirect.md @@ -60,7 +60,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { const base = "https://example.com"; const statusCode = 301; diff --git a/content/workers/examples/respond-with-another-site.md b/content/workers/examples/respond-with-another-site.md index 8187e0d91fa2fda..fe27749c9c37c21 100644 --- a/content/workers/examples/respond-with-another-site.md +++ b/content/workers/examples/respond-with-another-site.md @@ -21,7 +21,7 @@ layout: example ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { async function MethodNotAllowed(request) { return new Response(`Method ${request.method} not allowed.`, { status: 405, diff --git a/content/workers/examples/return-html.md b/content/workers/examples/return-html.md index ac4e89900514dc7..1f3d8720946d2f7 100644 --- a/content/workers/examples/return-html.md +++ b/content/workers/examples/return-html.md @@ -21,7 +21,7 @@ updated: 2024-01-11 ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { const html = `

Hello World

diff --git a/content/workers/examples/return-json.md b/content/workers/examples/return-json.md index 39591e55912fc4b..62e3bc76fa977d3 100644 --- a/content/workers/examples/return-json.md +++ b/content/workers/examples/return-json.md @@ -23,7 +23,7 @@ updated: 2024-01-11 ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { const data = { hello: "world", }; diff --git a/content/workers/examples/rewrite-links.md b/content/workers/examples/rewrite-links.md index 1d9c58906654974..47e8e6badaed6ee 100644 --- a/content/workers/examples/rewrite-links.md +++ b/content/workers/examples/rewrite-links.md @@ -57,7 +57,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { const OLD_URL = "developer.mozilla.org"; const NEW_URL = "mynewdomain.com"; diff --git a/content/workers/examples/security-headers.md b/content/workers/examples/security-headers.md index 34fddad4affca54..0196a98eac1426e 100644 --- a/content/workers/examples/security-headers.md +++ b/content/workers/examples/security-headers.md @@ -106,7 +106,7 @@ export default { ```ts export default { - async fetch(request: Request) { + async fetch(request: Request): Promise { const DEFAULT_SECURITY_HEADERS = { /* Secure your application with Content-Security-Policy headers. diff --git a/content/workers/examples/signing-requests.md b/content/workers/examples/signing-requests.md index 9588eb4c8b99aaf..f4ea5a7e7bdc7c9 100644 --- a/content/workers/examples/signing-requests.md +++ b/content/workers/examples/signing-requests.md @@ -148,7 +148,7 @@ const encoder = new TextEncoder(); const EXPIRY = 60; export default { - async fetch(request: Request, env: { SECRET_DATA: string }) { + async fetch(request: Request, env: { SECRET_DATA: string }): Promise { // You will need some secret data to use as a symmetric key. This should be // attached to your Worker as an encrypted secret. // Refer to https://developers.cloudflare.com/workers/configuration/secrets/ diff --git a/content/workers/examples/turnstile-html-rewriter.md b/content/workers/examples/turnstile-html-rewriter.md index 71aa8ecef65d49b..0a9c5b246a050ea 100644 --- a/content/workers/examples/turnstile-html-rewriter.md +++ b/content/workers/examples/turnstile-html-rewriter.md @@ -49,7 +49,7 @@ export default { ```ts export default { - async fetch(request: Request, env: Env) { + async fetch(request: Request, env: Env): Promise { const SITE_KEY = env.SITE_KEY let res = await fetch(request) diff --git a/content/workers/runtime-apis/rpc/typescript.md b/content/workers/runtime-apis/rpc/typescript.md index 17856f114ba4f12..6740d7590b1010c 100644 --- a/content/workers/runtime-apis/rpc/typescript.md +++ b/content/workers/runtime-apis/rpc/typescript.md @@ -22,7 +22,7 @@ interface Env { } export default { - async fetch(req: Request, env: Env, ctx: ExecutionContext) { + async fetch(req: Request, env: Env, ctx: ExecutionContext): Promise { const result = await env.SUM_SERVICE.sum(1, 2); return new Response(result.toString()); } diff --git a/content/workers/runtime-apis/web-crypto.md b/content/workers/runtime-apis/web-crypto.md index be85005819335b1..f9e8bfa788528a1 100644 --- a/content/workers/runtime-apis/web-crypto.md +++ b/content/workers/runtime-apis/web-crypto.md @@ -89,7 +89,7 @@ export default { {{}} ```ts export default { - async fetch(req: Request) { + async fetch(req: Request): Promise { // Fetch from origin const res = await fetch(req); diff --git a/content/workers/testing/vitest-integration/get-started/write-your-first-test.md b/content/workers/testing/vitest-integration/get-started/write-your-first-test.md index be4ac901514a555..15a19bf89fc883e 100644 --- a/content/workers/testing/vitest-integration/get-started/write-your-first-test.md +++ b/content/workers/testing/vitest-integration/get-started/write-your-first-test.md @@ -232,7 +232,7 @@ export default { filename: index.ts --- export default { - async fetch(request: Request, env: Env, ctx: ExecutionContext) { + async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise { const { pathname } = new URL(request.url); if(pathname === "/404") { diff --git a/content/workers/tutorials/upload-assets-with-r2/index.md b/content/workers/tutorials/upload-assets-with-r2/index.md index 3adfab01848163e..fce1c564fc53978 100644 --- a/content/workers/tutorials/upload-assets-with-r2/index.md +++ b/content/workers/tutorials/upload-assets-with-r2/index.md @@ -128,7 +128,7 @@ Now, add a new code path that handles a `PUT` HTTP request. This new code will c filename: worker.ts --- export default { - async fetch(request: Request, env: unknown) { + async fetch(request: Request, env: unknown): Promise { if (request.method === 'PUT') { // Note that you could require authentication for all requests // by moving this code to the top of the fetch function.