From 44877d7ca6e9b53c3ff5ab4a8e9107f339d27555 Mon Sep 17 00:00:00 2001 From: Philippe Date: Mon, 11 Dec 2023 20:32:37 +0100 Subject: [PATCH] Revert "Add temporary ping" This reverts commit e3526aea755f3d445c147c982f84fe06ca7a893d. --- utils/api.js | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/utils/api.js b/utils/api.js index d782cf63..a8e5695b 100644 --- a/utils/api.js +++ b/utils/api.js @@ -63,34 +63,29 @@ const fn = (cb, options = {}) => { }) : async (query) => logRuntime(() => addGeneratedTime(cb(query)), name, query, silenceParamsLog); - const apiCall = async (req, res) => { - // Async ping the new api for load testing - fetch(`https://d12bgb69hxhn2g.cloudfront.net${req.url}`); - - return ( - Promise.resolve(callback(req.query)) - .then((data) => { - if (maxAgeSec !== null) res.setHeader('Cache-Control', `max-age=0, s-maxage=${maxAgeSec}, stale-while-revalidate`); - res.status(200).json( - returnFlatData ? - data : - formatJsonSuccess(data) + const apiCall = async (req, res) => ( + Promise.resolve(callback(req.query)) + .then((data) => { + if (maxAgeSec !== null) res.setHeader('Cache-Control', `max-age=0, s-maxage=${maxAgeSec}, stale-while-revalidate`); + res.status(200).json( + returnFlatData ? + data : + formatJsonSuccess(data) + ); + }) + .catch((err) => { + if (IS_DEV) { + throw err; + } else { + const code = ( + (err instanceof ParamError) ? 200 : + (err instanceof NotFoundError) ? 404 : + 500 ); - }) - .catch((err) => { - if (IS_DEV) { - throw err; - } else { - const code = ( - (err instanceof ParamError) ? 200 : - (err instanceof NotFoundError) ? 404 : - 500 - ); - res.status(code).json(formatJsonError(err)); - } - }) - ); - }; + res.status(code).json(formatJsonError(err)); + } + }) + ); apiCall.straightCall = callback;