From 946e0865bdd207ead30c416870d84d93cab5b3a1 Mon Sep 17 00:00:00 2001 From: Mike Fix Date: Sat, 16 Oct 2021 16:30:48 -0700 Subject: [PATCH] use exising EXPORT_SIZES_HASH --- api/image/index.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/api/image/index.js b/api/image/index.js index 268a1d4..0615c69 100755 --- a/api/image/index.js +++ b/api/image/index.js @@ -4,6 +4,8 @@ const { json, send } = require('micro') const chrome = require('chrome-aws-lambda') const puppeteer = require('puppeteer-core') +const { EXPORT_SIZES_HASH } = require('../../lib/constants') + // TODO expose local version of dom-to-image const DOM_TO_IMAGE_URL = 'https://unpkg.com/dom-to-image@2.6.0/dist/dom-to-image.min.js' const NOTO_COLOR_EMOJI_URL = @@ -60,13 +62,9 @@ module.exports = async (req, res) => { const dataUrl = await page.evaluate((target = document) => { const query = new URLSearchParams(document.location.search) - const EXPORT_SIZES_HASH = { - '1x': '1', - '2x': '2', - '4x': '4', - } - - const exportSize = EXPORT_SIZES_HASH[query.get('es')] || '2' + const exportSize = EXPORT_SIZES_HASH[query.get('es')] + ? EXPORT_SIZES_HASH[query.get('es')].value + : 2 target.querySelectorAll('span[role="presentation"]').forEach(node => { if (node.innerText && node.innerText.match(/%[A-Fa-f0-9]{2}/)) {