
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
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.
knex-modeling
Advanced tools
A TypeScript modeling library that extends Knex for better typing and easier database modeling
A TypeScript modeling library that extends Knex for better typing and easier database modeling with automated migrations and interfaces.
npm install knex-modeling
# or
yarn add knex-modeling
npx knex-modeling init
npx knex-modeling generate-schema --name "User"
npx knex-modeling generate-migration
import { createModel, defineSchema } from 'knex-modeling'
const userSchema = defineSchema({
id: { type: 'increments', primary: true },
name: { type: 'string', required: true, maxLength: 255 },
email: { type: 'string', unique: true, required: true },
age: { type: 'integer', nullable: true },
isActive: { type: 'boolean', defaultTo: true },
createdAt: { type: 'timestamp', defaultTo: 'now' },
updatedAt: { type: 'timestamp', defaultTo: 'now' }
})
export const User = createModel({
schema: userSchema,
tableName: 'users'
})
// Create
const user = await User.create({
name: 'John Doe',
email: 'john@example.com',
age: 30
})
// Find
const users = await User.findAll()
const user = await User.findById(1)
// Update
await User.update({ id: 1 }, { age: 31 })
// Delete
await User.destroy({ id: 1 })
// Complex queries with joins
const results = await User
.complexQuery({
select: ['users.*', 'profiles.bio'],
joins: [
{ table: 'profiles', on: 'users.id = profiles.user_id' }
],
where: { 'users.isActive': true }
})
# Initialize new project
npx knex-modeling init
# Generate new schema
npx knex-modeling generate-schema --name "Product"
# Show configuration
npx knex-modeling config
# Generate migration from model changes
npx knex-modeling generate-migration
# Generate with custom name
npx knex-modeling generate-migration --name "add_user_preferences"
# Generate from existing migrations
npx knex-modeling generate-schemas-from-migrations
# Generate TypeScript interfaces
npx knex-modeling generate-interfaces
# Generate everything (migrations + interfaces)
npx knex-modeling generate-all
# Watch mode for auto-generation
npx knex-modeling watch
git clone https://github.com/your-username/knex-modeling.git
cd knex-modeling
npm install
# Build project
npm run build
# Build with watch mode
npm run build:dev
# Run tests
npm test
# Run tests with coverage
npm run test:ci
# Lint code
npm run lint
# Fix linting issues
npm run lint:fix
# Type checking
npm run typecheck
# Validate everything
npm run validate
# Patch version (1.0.0 -> 1.0.1)
npm run release
# Minor version (1.0.0 -> 1.1.0)
npm run release:minor
# Major version (1.0.0 -> 2.0.0)
npm run release:major
# Beta release
npm run publish:beta
The project includes a comprehensive CI/CD pipeline:
const schema = defineSchema({
// Numbers
id: { type: 'increments', primary: true },
count: { type: 'integer' },
price: { type: 'decimal', precision: 10, scale: 2 },
rating: { type: 'float' },
// Text
name: { type: 'string', maxLength: 255 },
description: { type: 'text' },
// Dates
createdAt: { type: 'timestamp', defaultTo: 'now' },
birthDate: { type: 'date' },
// Other
isActive: { type: 'boolean', defaultTo: true },
metadata: { type: 'json' },
tags: { type: 'jsonb' },
status: { type: 'enum', values: ['pending', 'active', 'inactive'] },
uuid: { type: 'uuid', defaultTo: 'uuid_generate_v4()' }
})
const schema = defineSchema({
email: {
type: 'string',
unique: true, // UNIQUE constraint
required: true, // NOT NULL
maxLength: 255, // VARCHAR(255)
index: true // CREATE INDEX
},
bio: {
type: 'text',
nullable: true, // Allow NULL
comment: 'User biography'
},
score: {
type: 'integer',
defaultTo: 0 // DEFAULT 0
}
})
ALTER TABLE// UP: Add columns and modify existing
export async function up(knex: Knex): Promise<void> {
await knex.schema.alterTable('users', (table) => {
table.string('phone', 20).nullable()
table.text('bio').nullable()
table.string('name', 500).notNullable().alter() // Safe length increase
})
}
// DOWN: Reverse all changes
export async function down(knex: Knex): Promise<void> {
await knex.schema.alterTable('users', (table) => {
table.string('name', 255).notNullable().alter()
table.dropColumn('bio')
table.dropColumn('phone')
})
}
// knex-modeling.config.js
module.exports = {
modelsDir: './src/models',
migrationsDir: './migrations',
interfacesDir: './interfaces'
}
The project includes optimized TypeScript configuration for both development and production builds.
git checkout -b feature/amazing-featuregit commit -m 'Add amazing feature'git push origin feature/amazing-featureThis project is licensed under the MIT License - see the LICENSE file for details.
FAQs
A TypeScript modeling library that extends Knex for better typing and easier database modeling
We found that knex-modeling 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.

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.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.