
Security News
Node.js Drops Bug Bounty Rewards After Funding Dries Up
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.
@dvsa/database-helpers
Advanced tools
Database wrapper to help with connection creation and use of MyBatis, published as a GitHub package.
.nvmrc for specific version)npm (If using n or nvm, this will be automatically managed)repo-security-scanner_<version>_Darwin_<architercture>.tar.gz and rename the executable inside the folder
to scanrepo - Add executable to path (using echo $PATH to find your path)npm install (or npm i)If wishing to add new top level directories to the output, then they must be included in the files array inside package.json as well as included in the clean:temp command.
In order to see the output of what will be published, run the following command:
npm publish --dry-run
There are two ways in which this package can/should be published:
main branch, the package will be published via a GHA workflow.MyBatisSession is a utility class that integrates MyBatis mapping with MySQL, allowing for structured and efficient query execution. It supports query execution, result transformation, and silent error handling while providing debugging capabilities.
MyBatisSession Classimport { MyBatisSession } from "@dvsa/database-helpers";
import { createConnection } from "mysql2/promise";
To use MyBatis, you need a MySQL connection, a namespace, and mapper files.
async function initializeSession() {
const connection = await createConnection({
host: "localhost",
user: "root",
password: "password",
database: "test_db",
});
const session = new MyBatisSession(connection, "UserNamespace", ["./mappers/user.xml"], true);
return session;
}
async function fetchUsers() {
const session = await initializeSession();
const users = await session.query("getUsers", {});
console.log("Users:", users);
await session.end();
}
fetchUsers();
class User {
id!: number;
name!: string;
}
async function getUserById(id: number) {
const session = await initializeSession();
const user = await session.selectOne("getUserById", { id }, User);
console.log("User:", user);
await session.end();
}
getUserById(1);
async function getAllUsers() {
const session = await initializeSession();
const users = await session.selectList("getAllUsers", {}, User);
console.log("Users:", users);
await session.end();
}
getAllUsers();
If you want to execute a query and return an empty array on failure, use selectAndCatchSilently.
async function getUsersSafely() {
const session = await initializeSession();
const users = await session.selectAndCatchSilently("getAllUsers", {}, User);
console.log("Users:", users);
await session.end();
}
getUsersSafely();
async function closeSession() {
const session = await initializeSession();
await session.end();
}
If debugMode is enabled (true), queries will be logged before execution.
*** Query for namespace: UserNamespace & mapperID: getUsers ***
SELECT * FROM users;
***
Errors will be thrown if:
Using selectAndCatchSilently, errors will be logged but return an empty array.
try {
const result = await session.query("invalidQuery", {});
} catch (error) {
console.error("Error executing query:", error);
}
FAQs
Common package to be used for database operations
We found that @dvsa/database-helpers demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 17 open source maintainers 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.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.