feat: removed node-worker-threads-pool as satori seems to be faster without it

This commit is contained in:
TresAbhi committed 2023-06-05 18:47:37 +00:00
1 parent 9e97c4a5ec
commit 632881c6b0
3 files changed
-43

No files matched your search

-1
View File
@@ -18,7 +18,6 @@
"fuzzysort": "^2.0.4",
"lodash.startcase": "^4.4.0",
"markdown-escape": "^2.0.0",
"node-worker-threads-pool": "^1.5.1",
"react": "^18.2.0",
"satori": "^0.9.1"
},
-37
View File
@@ -1,4 +1,3 @@
import { StaticPool } from 'node-worker-threads-pool';
import { WargamingResponse } from '../../types/wargamingResponse.js';
export type TankType = 'AT-SPG' | 'lightTank' | 'mediumTank' | 'heavyTank';
@@ -50,39 +49,3 @@ export const TIER_ROMAN_NUMERALS: Record<number, string> = {
export const TANK_IDS = Object.keys(tankopedia).map((id) => Number(id));
export const TANKS = TANK_IDS.map((id) => tankopedia[id]);
export const TANK_NAMES = TANKS.map((tank) => tank.name);
const imageEncodingStaticPool = new StaticPool({
size: 1,
task: async (data: Tankopedia) => {
console.log('Encoding tank images...');
const encoded: [number, string][] = [];
await Promise.all(
Object.entries(data as Tankopedia).map(
async ([, tank]: [string, TankopediaEntry]) => {
if (tank.images.normal) {
const response = await fetch(tank.images.normal);
const blob = await response.arrayBuffer();
const base64 = `data:${response.headers.get(
'content-type',
)};base64,${Buffer.from(blob).toString('base64')}`;
encoded.push([tank.tank_id, base64]);
}
},
),
);
console.log('Encoded tank images');
return encoded;
},
});
imageEncodingStaticPool.exec(tankopedia).then((encoded) => {
console.log('Implementing encoded images...');
encoded.forEach(([tankId, image]) => {
tankopedia[tankId].images.normal = image;
});
console.log('Implemented encoded images');
});
-5
View File
@@ -577,11 +577,6 @@ nanoid@^3.3.6:
resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz"
integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==
node-worker-threads-pool@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/node-worker-threads-pool/-/node-worker-threads-pool-1.5.1.tgz#1034303e10bb63a541ec74ae26559e9dff355f27"
integrity sha512-7TXAhpMm+jO4MfESxYLtMGSnJWv+itdNHMdaFmeZuPXxwFGU90mtEB42BciUULXOUAxYBfXILAuvrSG3rQZ7mw==
pako@^0.2.5:
version "0.2.9"
resolved "https://registry.yarnpkg.com/pako/-/pako-0.2.9.tgz#f3f7522f4ef782348da8161bad9ecfd51bf83a75"