Skip to main content
Module

x/shed/index.ts>RequestCookieStore

All Worker Tools under a single roof
Latest
class RequestCookieStore
implements CookieStore
Re-export
import { RequestCookieStore } from "https://deno.land/x/shed@v0.1.0-pre.10/index.ts";

An implementation of the Cookie Store API for request handlers.

It uses the Cookie header of a request to populate the store and keeps a record of changes that can be exported as a list of Set-Cookie headers.

Note that this is not a polyfill! It is intended as a cookie middleware for Cloudflare Workers, and perhaps some other uses.

Constructors

new
RequestCookieStore(request: Request)

Properties

readonly
headers: [string, string][]

Exports the recorded changes to this store as a list of Set-Cookie headers.

Can be passed as the headers field when building a new Response:

new Response(body, { headers: cookieStore.headers }) 

Methods

addEventListener(
_type: string,
_options?: boolean | AddEventListenerOptions,
): void
delete(name: string): Promise<void>
delete(options: CookieStoreDeleteOptions): Promise<void>
dispatchEvent(_event: Event): boolean
get(name?: string): Promise<CookieListItem | null>
get(options?: CookieStoreGetOptions): Promise<CookieListItem | null>
getAll(name?: string): Promise<CookieList>
removeEventListener(
_type: string,
_options?: boolean | EventListenerOptions,
): void
set(name: string, value: string): Promise<void>
set(options: CookieInit): Promise<void>

Exports the entire cookie store as a cookie header string

Static Methods

deprecated
toSetCookie(cookie: CookieInit): string

Helper to turn a single CookieInit into a set-cookie string.