import { CookieSerializeOptions , parse as parseCookie , serialize as serializeCookie } from 'cookie' ; const noCookies = Object . create ( null ) ; export class Cookies { private readonly requestCookies : Record < string , string > ; constructor ( requestHeaders , private readonly responseHeaders ) { const cookie = requestHeaders . get ( 'cookie' ) ; this . requestCookies = cookie ? parseCookie ( cookie ) : noCookies ; } public get ( name ) { return this . requestCookies [ name ] || null ; } public set ( name , val , options ? ) { this . responseHeaders . append ( 'Set-Cookie' , serializeCookie ( name , val , options ) ) ; } }