| 66 | } |
| 67 | |
| 68 | function getCookieParser(req: NowRequest) { |
| 69 | return function parseCookie(): NowRequestCookies { |
| 70 | const header: undefined | string | string[] = req.headers.cookie; |
| 71 | |
| 72 | if (!header) { |
| 73 | return {}; |
| 74 | } |
| 75 | |
| 76 | // eslint-disable-next-line @typescript-eslint/no-var-requires |
| 77 | const { parse } = require('cookie'); |
| 78 | return parse(Array.isArray(header) ? header.join(';') : header); |
| 79 | }; |
| 80 | } |
| 81 | |
| 82 | function setLazyProp<T>(req: NowRequest, prop: string, getter: () => T) { |
| 83 | const opts = { configurable: true, enumerable: true }; |