UNPKG

@taxum/cookie

Version:
25 lines 713 B
import { CookieJar } from "./jar.js"; /** * Extractor that grabs cookies from the request and returns a * {@link CookieJar}. * * When making modifications to the cookie jar, you need to return the jar * in the response. Any modified or removed cookies will yield a `Set-Cookie` * header in the response. * * @example * ```ts * import { cookieJar, Cookie } from "@taxum/cookie"; * import { extractHandler } from "@taxum/core/routing"; * * const handler = extractHandler(cookieJar, (jar) => { * jar.add(new Cookie("foo", "bar")); * * return [jar, ""]; * }); * ``` */ export const cookieJar = (req) => { return CookieJar.fromHeaders(req.headers); }; //# sourceMappingURL=extract.js.map