Skip to content

Commit e3526ae

Browse files
committed
Add temporary ping
1 parent 388fe9e commit e3526ae

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

utils/api.js

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,29 +63,34 @@ const fn = (cb, options = {}) => {
6363
}) :
6464
async (query) => logRuntime(() => addGeneratedTime(cb(query)), name, query, silenceParamsLog);
6565

66-
const apiCall = async (req, res) => (
67-
Promise.resolve(callback(req.query))
68-
.then((data) => {
69-
if (maxAgeSec !== null) res.setHeader('Cache-Control', `max-age=0, s-maxage=${maxAgeSec}, stale-while-revalidate`);
70-
res.status(200).json(
71-
returnFlatData ?
72-
data :
73-
formatJsonSuccess(data)
74-
);
75-
})
76-
.catch((err) => {
77-
if (IS_DEV) {
78-
throw err;
79-
} else {
80-
const code = (
81-
(err instanceof ParamError) ? 200 :
82-
(err instanceof NotFoundError) ? 404 :
83-
500
66+
const apiCall = async (req, res) => {
67+
// Async ping the new api for load testing
68+
fetch(`https://d12bgb69hxhn2g.cloudfront.net${req.url}`);
69+
70+
return (
71+
Promise.resolve(callback(req.query))
72+
.then((data) => {
73+
if (maxAgeSec !== null) res.setHeader('Cache-Control', `max-age=0, s-maxage=${maxAgeSec}, stale-while-revalidate`);
74+
res.status(200).json(
75+
returnFlatData ?
76+
data :
77+
formatJsonSuccess(data)
8478
);
85-
res.status(code).json(formatJsonError(err));
86-
}
87-
})
88-
);
79+
})
80+
.catch((err) => {
81+
if (IS_DEV) {
82+
throw err;
83+
} else {
84+
const code = (
85+
(err instanceof ParamError) ? 200 :
86+
(err instanceof NotFoundError) ? 404 :
87+
500
88+
);
89+
res.status(code).json(formatJsonError(err));
90+
}
91+
})
92+
);
93+
};
8994

9095
apiCall.straightCall = callback;
9196

0 commit comments

Comments
 (0)