chore: update to common redis + top markers account flag

This commit is contained in:
Jack Waller
2024-05-16 12:39:44 +10:00
parent cd26f39c72
commit 956a031fec
13 changed files with 1699 additions and 316 deletions

View File

@@ -11,8 +11,11 @@ import {
SerumSubscriber,
SpotMarketConfig,
SpotMarkets,
decodeUser,
isVariant,
} from '@drift-labs/sdk';
import { RedisClient } from '@drift/common';
import { logger } from './logger';
import { NextFunction, Request, Response } from 'express';
import FEATURE_FLAGS from './featureFlags';
@@ -338,6 +341,27 @@ export const validateDlobQuery = (
};
};
export const getAccountFromId = async (
userMapClient: RedisClient,
topMakers: string[]
) => {
return Promise.all(
topMakers.map(async (accountId) => {
const userMap = await userMapClient.getRaw(accountId);
if (userMap) {
return {
accountId,
account: decodeUser(Buffer.from(userMap.split('::')[1], 'base64')),
};
}
return {
accountId,
account: null,
};
})
).then((results) => results.filter((user) => !!user));
};
export function errorHandler(
err: Error,
_req: Request,