npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

express-mysql-framework

v1.0.6

Published

Database framework for Express.js

Readme

express-mysql-framework

Lightweight TypeScript helper for using Knex with MySQL in Express projects.

Overview

This small library provides a base Model class and a simple Knex db wrapper to make building database-backed models easier in TypeScript + Express apps.

Key features:

  • Minimal base Model with a table() helper that returns a Knex query builder.
  • Knex configuration driven by environment variables.

Quick start

  1. Install dependencies:
npm install
  1. Provide environment variables (see .env example below).

  2. Type-check only:

npx tsc --noEmit
  1. Build:
npm run build

Local .env example

Create a .env file at the project root (not committed to source control):

DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=root
DB_PASSWORD=secret
DB_NAME=my_database
NODE_ENV=development
DB_POOL_MIN=2
DB_POOL_MAX=10

Usage

Example usage in TypeScript source:

import UserModel from './src/User.mode.js';

const users = new UserModel();
const q = users.table().select('*').limit(10);
// await q to run query in async context

Notes:

  • Set protected tableName in model subclasses to match your database table.
  • The base Model defaults primaryKey to id.

package.json review (A → Z)

  • name: express-mysql-framework — OK for publishing if desired.
  • type: module — code uses ES module imports/exports.
  • main/module/types: point to ./dist/* — matches compiled output.
  • scripts: contains build (tsc) and lifecycle hooks (prepare, prepublishOnly).
  • dependencies: dotenv, knex, mysql2 — appropriate for runtime.
  • devDependencies: typescript, @types/node recommended and added.
  • repository/homepage: update to your repo if different from current value.
  • keywords: contains useful tags; duplicates were removed.

Scripts

  • build — compile TypeScript into dist using tsc.
  • prepare / prepublishOnly — run build steps before publishing.

Add a test script if you introduce tests.

Publishing checklist

  • Bump version in package.json for releases.
  • Confirm repository, bugs, and homepage point to the correct repository.
  • Run npm run build and verify dist contains index.js and .d.ts files.
  • Optionally add CI to run npx tsc --noEmit on PRs.

Recommendations

  • Install dev types for Node if not already present:
npm install -D @types/node
  • Consider adding a small integration test or local script that verifies DB connectivity using your .env settings.

Changes made

  • Added comments to src/Model.ts and src/db.ts.
  • Fixed src/User.mode.ts to use tableName and set a sensible default.
  • Removed duplicate keyword in package.json and added @types/node.

If you want, I can run npm install here to pull dependencies and then run npx tsc --noEmit to re-check types. Which would you like me to do next?