
Research
NPM targeted by malware campaign mimicking familiar library names
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
A promise batching utility mostly used in GraphQL resolvers to avoid N + 1 data fetching.
A promise batching utility mostly used in GraphQL resolvers to avoid N + 1 data fetching
npm add next-batch
import { nextBatch } from "next-batch";
// in your resolvers
User: {
tasks: async ({ id: userId }, _args, context) => {
// batch to collect all resolver requests that are flushed
// in the next execution frame using process.nextTick()
const tasksBatch = nextBatch({
// unique string key to collect all promises into a single batch
key: "tasks",
// batchHandler is the callback that will be invoked when the batch
// is flushed in the next tick. All keys from taskBatch.add(key)
// will be collected as an array and sent as an argument to this
// batchHandler callback
batchHandler: async (keys: { id: number }[]) => {
const tasks = await taskDB.findByUserIds({
ids: keys.map((key) => key.id),
});
// batch handler should return a Map with every key in keys arg
// and its corresponding value as a map entry.
// remember to use the same key reference and don't deconstruct
// and construct a new object as map key
const result = new Map<typeof keys[number], { title: string }>();
keys.forEach((key) => {
const task = tasks.filter((task) => task.id === key.id);
result.set(key, task);
});
return result;
},
});
// tasks are requested per user but resolved in batch for all users
// via the JavaScript magic of our next-batch util
const tasks = await tasksBatch.add({ id: userId });
return tasks;
};
}
MIT © Dinesh Pandiyan
FAQs
A promise batching utility mostly used in GraphQL resolvers to avoid N + 1 data fetching.
The npm package next-batch receives a total of 3 weekly downloads. As such, next-batch popularity was classified as not popular.
We found that next-batch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
Research
Socket's research uncovers three dangerous Go modules that contain obfuscated disk-wiping malware, threatening complete data loss.
Research
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.