import * as keywork from "https://deno.land/x/keywork@v6.2.1/mod.ts";
Keywork is a modular and opinionated library, providing structured guidence as your web app grows, without locking you into a specific pattern.
Features are categorized into modules that can be imported directly:
// highlight-next-line
import { RequestRouter } from 'keywork/router'
const app = new RequestRouter()
app.get('/', () => 'Hello there! 👋')
export default app
// highlight-next-line
import { RequestRouter } from 'https://deno.land/x/keywork/modules/router/mod.ts'
import { serve } from 'https://deno.land/std@0.140.0/http/server.ts'
const app = new RequestRouter()
serve((request) => app.fetch(request))
// highlight-next-line
import { RequestRouter } from 'https://esm.sh/keywork/router'
const app = new RequestRouter()
app.get('/', () => 'Hello there! 👋')
:::tip
While Keywork has many modules, modern bundlers and transpilers such as ESBuild will intelligently bundle only the Keywork modules you include in your web app.
- A full list of Keywork's modules are available in the navigation menu, however the most popular are shown below.
-
::
Namespaces
Keywork includes error utilities that pair nicely with HTTP request handlers. | |
Keywork uses the JavaScript Events API internally to handle HTTP requests. | |
Keywork includes utilities for working with files, such as determining the MIME type while handling an incoming HTTP request. | |
N HTTP | Keywork includes utilities for working with incoming HTTP requests,
and extends the native |
Keywork includes utilities for generating IDs. | |
Middleware are instances of the Keywork#Router.RequestRouter | | |
While optional, Keywork uses React as its primary HTML templating engine. | |
Designed with familiarity in mind, the server-side routing API is inspired by Express.js, React Router, and the native Cloudflare Workers platform. | |
Keywork includes promise-based utilities for working with the DOM. | |
Keywork uses JavaScript's built-in URL Pattern API to create pattern matchers. The syntax is based on path-to-regexp. Wildcards, named capture groups, regular groups, and group modifiers are all supported. |
Classes
An error class that feels fits nicely into an incoming HTTP request handler. | |
Extends the lifetime of the | |
An event object containing contextual data for a single and specific incoming HTTP request. | |
A client-side cachable response. | |
An error response sent to a client when a request is deemed to be invalid in some way. | |
A response that returns a full HTML document. | |
A response sent to the client containing a JSON object. | |
Given that a request's etag header matches an server entity or resource,
a | |
A basic implementation of Twitter's original Snowflake ID system. | |
A isomorphic logger available in both the browser and worker environments. | |
Handles incoming requests for static assets uploaded to Cloudflare Pages. | |
Middleware that given a | |
A router that proxies requests directly to a Cloudflare Worker environment binding, such as a service binding. | |
Middleware to manage and authenticate your users. | |
Handles incoming requests for static assets uploaded to Cloudflare KV. | |
Routes incoming HTTP requests from the user's browser to your app's route endpoints. | |
Routes incoming HTTP requests from the user's browser to your app's route endpoints. |
Enums
Standard HTTP status codes. | |
Variables
Used in place of the reference-sensitive | |
A record of all the status codes text. | |
Returns the given | |
Determines if the given HTTP status status is a client error. | |
Determines if the given HTTP status code is informational. | |
Determines if the given HTTP status status is a redirection. | |
Determines if the given HTTP status status is a server error. | |
Determines if the given HTTP status code is successful. | |
Given a standard uppercase HTTP method verb such as | |
Given a standardized uppercase method verb such as | |
Stringifies JSON into an indented string. | |
An asset environment binding available within Cloudflare Pages. | |
An asset environment binding available within Cloudflare Pages. | |
The default cookie serialization options. | |
The default session cookie key. | |
Embeds the given SSR props in the DOM for client-side hydration. | |
The global key where SSR props are assigned.
This includes a ':' character to prevent | |
A server-side render of a given HTML document. | |
The default ID assigned to the React root element. | |
The default ID assigned to the React root style element. | |
Used in place of the reference-sensitive | |
Resolves a POSIX-like path into slash delineated segments. |
Functions
Infers the appropriate Response constructor for the given | |
Clones a given | |
Checks if a given MIME-type is compressible. | |
Checks if the given object is an instance of | |
Checks if the given object is an instance of | |
Checks if the given object is shaped like a | |
A convenience wrapper around | |
Renders the given React content to an HTML stream. | |
A route request handler for redirecting requests. | |
Checks if a given object is shaped like a KeyworkFetcher | |
Utility function for parsing middleware options. | |
Converts a given | |
Converts a given | |
Convenience method to get a substring's start offset. | |
Converts a given | |
Promise wrapper around | |
Creates a promise that blocks until the DOM has loaded. | |
Converts a given | |
Converts a given |
Interfaces
A JSON representation of a | |
Additional data associated with the | |
A simple session manager to aid in authenticating users. | |
An environment binding available within Worker Sites.
This is often used with the | |
Options to configure the Worker Router. | |
Cloudflare UsageEvents are handled by defining and exporting an object with method handlers that correspond to event names: | |
Middleware implementation of | |
Public endpoints to aid in debugging your app.
Available at | |
Options to configure the Worker Router. | |
A function or method that handles incoming requests and replies with a | |
An environment binding within a worker that has a |
Type Aliases
HTTP method verbs. | |
An object that has a | |
Either a full | |
Normalized HTTP methods in a JavaScript friendly format. | |
The compression format used when encoding the response body. | |
A component which wraps the current SSR routes. Use this if you need to inject a provider into the SSR pipeline. | |
Either: | |
Middleware declaration in the convenient shape of | |
Either an instance of |