
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Generates TypeScript types for Knex.js using MySQL tables.
Create knexfile.js:
module.exports = {
client: 'mysql2',
connection: {
host: '127.0.0.1',
port: 3306,
database: 'db',
user: 'user',
password: 'password',
charset: 'utf8mb4',
},
};
Run:
npx m2tk --prefix=Db > src/db/DbTypes.ts
You can put the command into your package.json scripts section:
{
"scripts": {
"types": "m2tk --prefix=Db > src/core/services/DbTypes.ts"
}
}
This command will generate DbTypes.ts with contents like:
import { Knex } from 'knex';
export interface DbUser {
id: number;
createdAt: Date;
username: string;
password: string;
}
export class DB {
constructor(public readonly knex: Knex) {}
get authenticators() {
return this.knex<DbUser>('users');
}
}
You could use the generated class in the folloing manner:
db.ts:
import knex from 'knex';
import { DB } from './DbTypes';
import { config } from './config';
import { registerService } from './registerService';
class DBT extends DB {
transaction<T>(callback: (db: DB) => Promise<T>) {
return this.knex.transaction((trx) => callback(new DB(trx)));
}
}
export const db = new DBT(
knex({
client: 'mysql2',
// ...
})
);
Somewhere in the app:
const user = await db.users.where({ username: input.username }).first();
// user is DbUser | undefined
FAQs
MySQL to TypeScript Knex adapter
We found that m2tk demonstrated a healthy version release cadence and project activity because the last version was released less than 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

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