kv-asset-handler | Routes requests to KV assets | Key Value Database library

 by   cloudflare TypeScript Version: v0.3.0 License: Apache-2.0

kandi X-RAY | kv-asset-handler Summary

kandi X-RAY | kv-asset-handler Summary

kv-asset-handler is a TypeScript library typically used in Database, Key Value Database applications. kv-asset-handler has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

kv-asset-handler is an open-source library for managing the retrieval of static assets from Workers KV inside of a Cloudflare Workers function. kv-asset-handler is designed for use with Workers Sites, a feature included in Wrangler, our command-line tool for deploying Workers projects. kv-asset-handler runs as part of a Cloudflare Workers function, so it allows you to customize how and when your static assets are loaded, as well as customize how those assets behave before they're sent to the client.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              kv-asset-handler has a low active ecosystem.
              It has 240 star(s) with 52 fork(s). There are 26 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 23 open issues and 62 have been closed. On average issues are closed in 122 days. There are 5 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of kv-asset-handler is v0.3.0

            kandi-Quality Quality

              kv-asset-handler has 0 bugs and 0 code smells.

            kandi-Security Security

              kv-asset-handler has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              kv-asset-handler code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              kv-asset-handler is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              kv-asset-handler releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of kv-asset-handler
            Get all kandi verified functions for this library.

            kv-asset-handler Key Features

            No Key Features are available at this moment for kv-asset-handler.

            kv-asset-handler Examples and Code Snippets

            No Code Snippets are available at this moment for kv-asset-handler.

            Community Discussions

            QUESTION

            Accessing Compressed Data for Cloudflare Workers Sites
            Asked 2020-Nov-15 at 20:54

            My cloudflare workers site houses binary data that a react app fetches. This binary data is stored as gzip compressed as it compresses extremely well (we're talking about a 20-25x reduction and uncompressed it is too large to fit in the 10MB KV limit). The problem I'm running into is that either the worker returns the data without the appropriate header:

            ...

            ANSWER

            Answered 2020-Nov-15 at 20:54

            This is an unfortunate wart of the Service Workers spec -- it's designed for use in the browser, where it expects response bodies to be decompressed before the worker runs, and does not expect they will be transmitted over the network again. To make things consistent, Cloudflare Workers has to recompress the data according to the content-encoding header when transmitting. But this in turn means there's no way to serve data that is already compressed.

            To solve this, we (Cloudflare) have added a non-standard Response option called encodeBody, which can be "auto" (the default) or "manual" (assumes the body is already compressed).

            So you can write code like this:

            Source https://stackoverflow.com/questions/64836479

            QUESTION

            What are cloudflare KV preview_ids and how to get one?
            Asked 2020-Sep-20 at 11:08

            I have a following wrangler.toml. When I would like to use dev or preview (e.g. npx wrangler dev or npx wrangler preview) wrangler asks to add a preview_id to the KV namespaces. Is this an identifier to an existing KV namespace?

            I see there is a ticket in Cloudflare Workers GH at https://github.com/cloudflare/wrangler/issues/1458 that tells this ought to be clarified but the ticket is closed with adding an error message

            In order to preview a worker with KV namespaces, you must designate a preview_id in your configuration file for each KV namespace you'd like to preview."

            which is the reason I'm here. :)

            As for larger context I would be really glad if someone could clarify: I see that if I give a value of an existing namespace, I can preview and I see a KV namespace of type __some-worker-dev-1234-workers_sites_assets_preview is generated in Cloudflare. This has a different identifier than the KV namespace pointed by the identifier used in the preview_id and the KV namespace pointed by the identifier I used in preview_id is empty. Why does giving an identifier of an existing KV namespace remove the error message, deploys the assets and allow for previwing but the actual KV namespace is empty and a new one is created?

            How do does kv-asset-handler know to look into this generated namespace to retrieve the assets?

            I'm currently testing with the default generated Cloudare Worker to my site and I wonder if I have misunderstood something or if there is some mechanics that bundles during preview/publish the site namespace to the scipt.

            If there is some random mechanics with automatic mapping, can this be then so that every developer can have their own private preview KV namespace?

            ...

            ANSWER

            Answered 2020-Aug-10 at 16:45

            This answer applies to versions of Wrangler >= 1.10.0

            wrangler asks to add a preview_id to the KV namespaces. Is this an identifier to an existing KV namespace?

            Yes! The reason there is a different identifier for preview namespaces is so that when developing with wrangler dev or wrangler preview you don't accidentally write changes to your existing production data with possibly buggy or incompatible code. You can add a --preview flag to most wrangler kv commands to interact with your preview namespaces.

            For your situation here there are actually a few things going on.

            1. You are using Workers Sites
            2. You have a KV namespace defined in wrangler.toml

            Workers Sites will automatically configure a production namespace for each environment you run wrangler publish on, and a preview namespace for each environment you run wrangler dev or wrangler preview on. If all you need is Workers Sites, then there is no need at all to specify a kv-namepsaces table in your manifest. That table is for additional KV namespaces that you may want to read data from or write data to. If that is what you need, you'll need to configure your own namespace and add id to wrangler.toml if you want to use wrangler publish, and preview_id (which should be different) if you want to use wrangler dev or wrangler preview.

            Source https://stackoverflow.com/questions/63332306

            QUESTION

            How to get Angular app working with Cloudflare Workers - Workers Sites
            Asked 2020-Feb-28 at 03:42

            I am struggling to get an SPA working using Angular with Cloudflare's Workers Sites. I am following the tutorial found here (but supplementing steps for Angular- not React), and everything is fine until however once published I am getting the browser error - could not find index.html in your content namespace

            My troubleshooting thus far has let me to link below:

            https://github.com/cloudflare/kv-asset-handler#servesinglepageapp

            however I am unsure how to configure/use this guidance for Angular so that it solves my above problem.

            ...

            ANSWER

            Answered 2020-Feb-28 at 03:42

            The wrangler.toml file should have the build folder on [site].bucket pointing to ./dist/ instead of ./build as seen in the guide.

            Source https://stackoverflow.com/questions/60442786

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install kv-asset-handler

            Add this package to your package.json by running this in the root of your project's directory:.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/cloudflare/kv-asset-handler.git

          • CLI

            gh repo clone cloudflare/kv-asset-handler

          • sshUrl

            git@github.com:cloudflare/kv-asset-handler.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link