import redis from './redis.js'; export async function getIdsBySlug(slugs, domain, toMap) { if (!slugs) { return []; } const ids = await Promise.all(slugs.map(async (slug) => { if (!slug) { return null; } /* this, naturally, fails if the slug is 69 etc. if (Number(slug)) { return Number(slug); // already an ID or missing } */ const id = await redis.hGet(`traxxx:${domain}:id_by_slug`, slug); return Number(id); })); if (toMap) { return Object.fromEntries(slugs.map((slug, index) => [slug, ids[index]])); } return ids.filter(Boolean); }