From 2a6b2171f5aa6711beefc50630f7cb71496c5c36 Mon Sep 17 00:00:00 2001 From: hazycora Date: Thu, 3 Aug 2023 02:13:34 -0500 Subject: [PATCH] use node-fetch --- package.json | 3 ++- pnpm-lock.yaml | 42 ++++++++++++++++++++++++++++++++++++++++++ server.js | 3 +++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index de272de..7c3cc4c 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "dependencies": { "@besties/html2png": "^0.1.8", "eta": "^3.1.0", - "express": "^4.18.2" + "express": "^4.18.2", + "node-fetch": "^3.3.2" }, "type": "module", "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 83d4917..e07fdc2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,9 @@ dependencies: express: specifier: ^4.18.2 version: 4.18.2 + node-fetch: + specifier: ^3.3.2 + version: 3.3.2 devDependencies: eslint: @@ -424,6 +427,11 @@ packages: engines: {node: '>= 6'} dev: false + /data-uri-to-buffer@4.0.1: + resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} + engines: {node: '>= 12'} + dev: false + /debug@2.6.9: resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} peerDependencies: @@ -725,6 +733,14 @@ packages: reusify: 1.0.4 dev: true + /fetch-blob@3.2.0: + resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==} + engines: {node: ^12.20 || >= 14.13} + dependencies: + node-domexception: 1.0.0 + web-streams-polyfill: 3.2.1 + dev: false + /fflate@0.7.4: resolution: {integrity: sha512-5u2V/CDW15QM1XbbgS+0DfPxVB+jUKhWEKuuFuHncbk3tEEqzmoXL+2KyOFuKGqOnmdIy0/davWF1CkuwtibCw==} dev: false @@ -779,6 +795,13 @@ packages: resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==} dev: true + /formdata-polyfill@4.0.10: + resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==} + engines: {node: '>=12.20.0'} + dependencies: + fetch-blob: 3.2.0 + dev: false + /forwarded@0.2.0: resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} engines: {node: '>= 0.6'} @@ -1142,6 +1165,20 @@ packages: lower-case: 1.1.4 dev: false + /node-domexception@1.0.0: + resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} + engines: {node: '>=10.5.0'} + dev: false + + /node-fetch@3.3.2: + resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + data-uri-to-buffer: 4.0.1 + fetch-blob: 3.2.0 + formdata-polyfill: 4.0.10 + dev: false + /node-html-parser@6.1.5: resolution: {integrity: sha512-fAaM511feX++/Chnhe475a0NHD8M7AxDInsqQpz6x63GRF7xYNdS8Vo5dKsIVPgsOvG7eioRRTZQnWBrhDHBSg==} dependencies: @@ -1671,6 +1708,11 @@ packages: engines: {node: '>= 0.8'} dev: false + /web-streams-polyfill@3.2.1: + resolution: {integrity: sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==} + engines: {node: '>= 8'} + dev: false + /which@2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} diff --git a/server.js b/server.js index 005b4d9..ad9c0da 100644 --- a/server.js +++ b/server.js @@ -2,6 +2,9 @@ import express from 'express' import { Eta } from 'eta' import render, { renderHtml } from './lib/render.js' import languageColors from './lib/languagecolors.js' +import fetch from 'node-fetch' +// satori is using the native fetch api, causing a warning, so make node-fetch the default +globalThis.fetch = fetch const debug = process.env.DEBUG ? true : false