better-auth
Version:
The most comprehensive authentication framework for TypeScript.
1 lines • 1.2 kB
Source Map (JSON)
{"version":3,"file":"node.mjs","names":["toNode"],"sources":["../../src/integrations/node.ts"],"sourcesContent":["import type { IncomingHttpHeaders } from \"node:http\";\nimport { toNodeHandler as toNode } from \"better-call/node\";\nimport type { Auth } from \"../types\";\n\nexport const toNodeHandler = (\n\tauth:\n\t\t| {\n\t\t\t\thandler: Auth[\"handler\"];\n\t\t }\n\t\t| Auth[\"handler\"],\n) => {\n\treturn \"handler\" in auth ? toNode(auth.handler) : toNode(auth);\n};\n\nexport function fromNodeHeaders(nodeHeaders: IncomingHttpHeaders): Headers {\n\tconst webHeaders = new Headers();\n\tfor (const [key, value] of Object.entries(nodeHeaders)) {\n\t\tif (value !== undefined) {\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tvalue.forEach((v) => webHeaders.append(key, v));\n\t\t\t} else {\n\t\t\t\twebHeaders.set(key, value);\n\t\t\t}\n\t\t}\n\t}\n\treturn webHeaders;\n}\n"],"mappings":";;;AAIA,MAAa,iBACZ,SAKI;AACJ,QAAO,aAAa,OAAOA,gBAAO,KAAK,QAAQ,GAAGA,gBAAO,KAAK;;AAG/D,SAAgB,gBAAgB,aAA2C;CAC1E,MAAM,aAAa,IAAI,SAAS;AAChC,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,YAAY,CACrD,KAAI,UAAU,OACb,KAAI,MAAM,QAAQ,MAAM,CACvB,OAAM,SAAS,MAAM,WAAW,OAAO,KAAK,EAAE,CAAC;KAE/C,YAAW,IAAI,KAAK,MAAM;AAI7B,QAAO"}