
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
mongodb-caching
Advanced tools
MongoDB with automatic Caching functionality using Keyv.
# npm
npm install mongodb-caching
# yarn
yarn add mongodb-caching
# pnpm
pnpm i mongodb-caching
These functions automatically handle caching
NOTE: When you update/insert/delete a document, the cache is not updated, you'll need to manually clear the cache using customClass.clear()
or customClass.keyv.clear()
import { MongoClient } from "mongodb";
import MongoDBCaching from "mongodb-caching";
interface UserCollectionSchema {
username: string;
}
class User extends MongoDBCaching<UserCollectionSchema> {
create(username: string) {
//* this.collection refers to MongoDB.Db.Collection
return this.collection.insertOne({ username });
}
getUser(username: string) {
//* Internally handles caching
return this.findOne({ username });
}
}
async function run() {
const mongodb = new MongoClient("mongoUri");
const userCollection = new User(mongodb.db("main").collection("users"));
await userCollection.create("Timeraa");
console.log(await userCollection.getUser("Timeraa"));
}
run();
import { MongoClient } from "mongodb";
import MongoDBCaching from "mongodb-caching";
interface UserCollectionSchema {
username: string;
ip: string;
}
interface Context {
ip: string;
}
class User extends MongoDBCaching<UserCollectionSchema, Context> {
create(username: string) {
//* this.collection refers to MongoDB.Db.Collection
return this.collection.insertOne({
username,
ip: this.context!.ip
});
}
getUser(username: string) {
//* Internally handles caching
return this.findOne({ username });
}
}
async function run() {
const mongodb = new MongoClient("mongoUri");
const userCollection = new User(mongodb.db("main").collection("users"));
//* Context would be set in let's say a middleware
userCollection.setContext({ ip: "someIp" });
await userCollection.create("Timeraa");
console.log((await userCollection.getUser("Timeraa"))?.ip);
}
run();
FAQs
MongoDB with automatic Caching functionality using Keyv.
The npm package mongodb-caching receives a total of 14 weekly downloads. As such, mongodb-caching popularity was classified as not popular.
We found that mongodb-caching 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
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.