| 8 | } |
| 9 | |
| 10 | export class CookieStore { |
| 11 | store: Record<string, Cookie>; |
| 12 | constructor(cookies?: Record<string, string>) { |
| 13 | this.store = |
| 14 | (cookies && |
| 15 | Object.entries(cookies).reduce( |
| 16 | (prev, [name, value]) => ({ |
| 17 | ...prev, |
| 18 | [name]: { name, value }, |
| 19 | }), |
| 20 | {} |
| 21 | )) || |
| 22 | {}; |
| 23 | } |
| 24 | add(name: string, cookie: Cookie) { |
| 25 | this.store = { |
| 26 | ...this.store, |
| 27 | [name]: cookie, |
| 28 | }; |
| 29 | } |
| 30 | map(callbackfn: (value: Cookie) => unknown) { |
| 31 | return Object.values(this.store).map(callbackfn); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | function setCookie(res: any, cookie: Cookie) { |
| 36 | // Preserve any existing cookies that have already been set in the same session |
nothing calls this directly
no outgoing calls
no test coverage detected