Skip to content

Commit

Permalink
Revert "Add temporary ping"
Browse files Browse the repository at this point in the history
This reverts commit e3526ae.
  • Loading branch information
philippe-git committed Dec 11, 2023
1 parent e3526ae commit 44877d7
Showing 1 changed file with 22 additions and 27 deletions.
49 changes: 22 additions & 27 deletions utils/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 44877d7

Please sign in to comment.