Git Product home page Git Product logo

worker-sites-template's People

Contributors

a-robinson avatar adamschwartz avatar ashleygwilliams avatar ashleymichal avatar caass avatar everlastingbugstopper avatar exvuma avatar ispivey avatar jbampton avatar kristianfreeman avatar mjackson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

worker-sites-template's Issues

remove readme

OR exclude it in a template exclude doc (feature of cargo-generate)

Unable to Catch Errors?

This template uses the following pattern,

addEventListener('fetch', event => {
  try {
    event.respondWith(handleEvent(event))
  } catch (e) {
      ...
  }
})

async function handleEvent(event) { ... }

However,

  1. event.respondWith is required to be called in the handler without await()ing. Failing to do so yields a warning from Cloudflare (See below)
  2. Because handleEvent is async, it will always return a Promise. It's not possible for the try/catch block to ever catch an error within handleEvent() without making the event handler async and then await()ing on handleEvent (which violates the first point).

Therefore, no exceptions thrown within handleEvent will ever be caught by this boilerplate code.

Here is a demonstrative repository: https://github.com/doublemarked/cf-workers-error-handling


Warning from Cloudflare when trying to asynchronously call event.respondWith:
FetchEvent handler did not call respondWith() before returning, but initiated some asynchronous task. That task will be canceled and default handling will occur -- the request will be sent unmodified to your origin. Remember that you must call respondWith() before the event handler returns, if you don't want default handling. You cannot call it asynchronously later on. If you need to wait for I/O (e.g. a subrequest) before generating a Response, then call respondWith() with a Promise (for the eventual Response) as the argument.

Server Side Includes

Hello,

I am not sure if this is the right place to ask this, if not please point me in the right direction. I am new to workers (and serverless in general).

I am currently trying out workers sites for some of my static sites, but a feature that I often use in NGINX is SSI, or server side includes.

I mainly do this as a basic "templating engine", so I can separate a website into header, footer, etc. files to make it easier for me to deploy changes that effect all pages without modifying all the individual pages.

I am wondering if there is any way for me to use SSI with workers sites, or if there is a branch/fork where someone has been kind enough to add support, as it would be greatly appreciated.

Thanks!

serverless.yml example?

Is it possible to make it work with Serverless Framework? If so, could you please provide an example serverless.yml to facilitate serverless deploy?

The use case for that is to have both Workers Site and Workers in the same repo, all managed by a single serverless.yml config and deployable via single serverless deploy command. It is possible to have multiple Cloudflare Workers in the same repo now, but the question is whether it is possible to add Workers Site there as well.

Expires header

Why don’t static assets like SVGs have an expire or max-age header?

Include keyModifier example

By default we should show how the user can use the keyModifier, specifically:

  • look up _index.html for dirs and page.html for pages
  • handle prefix trimming

Cloudflare TaskDEV

TaskDEV is a custom Machine Learning Provision, Similar to a runner but has a programmed MAP to complete the task and evolve into a bigger code emulation. TaskDEVS will Finish the task, But use other Emulation Sessions to learn off the previous creations.image

Workers Sites and Apps

Is there any way to get Cloudflare Apps working together with a static site deployed with Workers Sites? It seems that Apps aren't running on Workers Sites.

remove the public directory

we want the contents of the worker-site directory to be primarily concerned with how sites are deployed, rather than the content they deploy. the idea of a sample public directory is not necessarily bad, but it should not be adjacent to the other contents of this template; that is, index.js, package.json, and .gitignore will ultimately go into the workers-site directory, and a public directory would be placed as a sibling to that directory.

simplest impl is to just not include this directory. open to other thoughts with the caveat that leaving this will likely demand additional work on the wrangler side.

serve 404.html on asset miss

for our template, we should set the worker up to serve a 404.html when the response comes back without an asset.

Autodeploy to stackbit.com

Alright,

love wrangler and sites, but to get things on steroids, it would be amazing to deploy Jam sites created in Stackbit directly to CF.

stackbit.com

Not sure what CloudFlare needs to do for that, but please talk to the guys at stackbit b/c getting a complete JAMstack site with a headless CMS on CF in under a minute is pretty appealing not only to me.

Add default 404 page

If this worker is deployed and nothing is returned from KV,

if (body.byteLength === 0) {
  return new Response("not found", {status:404, statusText:"not found"})
}

Options object ignored, when getting "404.html"

If DEBUG is set to false, the request that fetches the 404 page doesn' honor the options that are set above.

I have changed the following:

        let notFoundResponse = await getAssetFromKV(event, {
          mapRequestToAsset: req => new Request(`${new URL(req.url).origin}/404.html`, req),
        })

...to this:

        options.mapRequestToAsset = req =>
          new Request(`${new URL(req.url).origin}/404.html`, req)
        let notFoundResponse = await getAssetFromKV(event, options)

...which fixed the problem.

The link to workers.cloudflare.com on the Hello World site resolves as a relative path

🐛 Bug Report

Environment

  • output of wrangler -V:
    wrangler 1.4.0-rc.1

Steps to reproduce

Generate a new site, fill your account ID into the wrangler.toml file, then run wrangler publish without modifying anything else. This should create a site with the default Hello World template. The page has a link to workers.cloudflare.com on it.

What did you expect to see?

I clicked the link and expected to go to workers.cloudflare.com

What did you see instead?

I clicked the link and went to <site-name>.<subdomain>.workers.dev/workers.cloudflare.com

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.