41
src/index.ts
41
src/index.ts
@@ -475,6 +475,47 @@ const main = async (): Promise<void> => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get('/batchPriorityFees', async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { marketIndex, marketType } = req.query;
|
||||||
|
|
||||||
|
const normedParams = normalizeBatchQueryParams({
|
||||||
|
marketIndex: marketIndex as string | undefined,
|
||||||
|
marketType: marketType as string | undefined,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (normedParams === undefined) {
|
||||||
|
res
|
||||||
|
.status(400)
|
||||||
|
.send(
|
||||||
|
'Bad Request: all params for batch request must be the same length'
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fees = await Promise.all(
|
||||||
|
normedParams.map(async (normedParam) => {
|
||||||
|
const fees = await redisClients[
|
||||||
|
parseInt(process.env.HELIUS_REDIS_HOST_INDEX) ?? 0
|
||||||
|
].client.get(
|
||||||
|
`priorityFees_${normedParam['marketType']}_${normedParam['marketIndex']}`
|
||||||
|
);
|
||||||
|
return JSON.parse(fees);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fees && fees.length > 0) {
|
||||||
|
res.status(200).json(fees);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
res.writeHead(404);
|
||||||
|
res.end('Not found');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
next(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
app.get('/topMakers', async (req, res, next) => {
|
app.get('/topMakers', async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
|
|||||||
@@ -146,15 +146,14 @@ async function main() {
|
|||||||
ws.send(
|
ws.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
channel: requestChannel,
|
channel: requestChannel,
|
||||||
error:
|
error: 'Error subscribing to channel',
|
||||||
'Error subscribing to channel'
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
ws.close(
|
ws.close(
|
||||||
1003,
|
1003,
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
error: 'Error subscribing to channel'
|
error: 'Error subscribing to channel',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -219,16 +218,14 @@ async function main() {
|
|||||||
ws.send(
|
ws.send(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
channel: requestChannel,
|
channel: requestChannel,
|
||||||
error:
|
error: 'Error unsubscribing from channel',
|
||||||
'Error unsubscribing from channel'
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
ws.close(
|
ws.close(
|
||||||
1003,
|
1003,
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
error:
|
error: 'Error unsubscribing from channel',
|
||||||
'Error unsubscribing from channel'
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user