more robust promise.all
This commit is contained in:
10
src/index.ts
10
src/index.ts
@@ -1000,6 +1000,8 @@ const main = async (): Promise<void> => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let hasError = false;
|
||||||
|
let errorMessage = '';
|
||||||
const l2s = await Promise.all(
|
const l2s = await Promise.all(
|
||||||
normedParams.map(async (normedParam) => {
|
normedParams.map(async (normedParam) => {
|
||||||
const { normedMarketType, normedMarketIndex, error } =
|
const { normedMarketType, normedMarketIndex, error } =
|
||||||
@@ -1011,7 +1013,8 @@ const main = async (): Promise<void> => {
|
|||||||
normedParam['marketName'] as string
|
normedParam['marketName'] as string
|
||||||
);
|
);
|
||||||
if (error) {
|
if (error) {
|
||||||
res.status(400).send(`Bad Request: ${error}`);
|
hasError = true;
|
||||||
|
errorMessage = `Bad Request: ${error}`;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1136,6 +1139,11 @@ const main = async (): Promise<void> => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (hasError) {
|
||||||
|
res.status(400).send(errorMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end(JSON.stringify({ l2s }));
|
res.end(JSON.stringify({ l2s }));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user