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

node-forge-cli

v1.0.2

Published

A Node.js CLI toolkit for scaffolding controllers, models, routes, views, and migrations with multi-database support

Readme

Node CLI Scaffolding & Migration Toolkit

A lightweight Node.js CLI toolkit for generating project resources and managing database setup, migrations, and seeders.

This package helps you quickly scaffold common backend files such as controllers, models, routes, views, seeders, migrations, and full resources, while also supporting database configuration and migration workflows.


Features

Database Operations

  • Database setup generator
  • Migration runner
  • Fresh migration support
  • Seeder execution
  • Rollback support

CLI Generators

  • Controller
  • Model
  • Migration
  • Seeder
  • View
  • Route
  • Database config
  • Full resource scaffold

All commands are implemented through Node-based CLI scripts under the cli/ and database/ directories.


Supported Databases

| Database | Driver | |-------------|----------------------| | MySQL | mysql2 | | PostgreSQL | pg | | MongoDB | mongoose | | Cassandra | cassandra-driver | | Redis | ioredis |

Configuration values are pulled from environment variables in .env.example and loaded through config/database.js.


Installation

Clone or copy the package into your project, then install dependencies:

npm i node-forge-cli

For automatic database dependency setup, run:

node-forge migration

The database setup script creates .env.example, config/database.js, and utils/database.js, and installs required database packages such as dotenv, mysql2, pg, mongoose, cassandra-driver, and ioredis.


Package Scripts

Add these scripts to your package.json:

{
  "scripts": {
    "migration":          "node-forge-forge database/setup.js",
    "migrate":            "node-forge database/migrate.js",
    "migrate:fresh":      "node-forge database/migrate.js fresh",
    "migrate:fresh-seed": "node-forge database/migrate.js fresh --seed",
    "migrate:rollback":   "node-forge database/migrate.js rollback",
    "make:controller":    "node-forge cli/make-controller.js",
    "make:model":         "node-forge cli/make-model.js",
    "make:migration":     "node-forge cli/make-migration.js",
    "make:seeder":        "node-forge cli/make-seeder.js",
    "make:view":          "node-forge cli/make-view.js",
    "make:route":         "node-forge cli/make-route.js",
    "make:database":      "node-forge cli/make-database.js",
    "make:resource":      "node-forge cli/make-scaffold.js"
  }
}

Usage

1. Setup Database Files

node-forge migration

Prepares database-related configuration files and environment variables. You can also pass a database driver directly:

node-forge database/setup.js mysql
node-forge database/setup.js postgres
node-forge database/setup.js mongodb
node-forge database/setup.js redis

2. Run Migrations

node-forge migrate

Runs all migration files from the database directory.

3. Run Fresh Migrations with Seeders

node-forge migrate:fresh-seed

Refreshes all migrations and then executes all seeders from the database/seeders directory.

4. Rollback Migrations

node-forge migrate:rollback

Executes the down() method of migrations in reverse order.


Generators

Create a Controller

node-forge make:controller user
node-forge make:controller admin/user

Creates controller files inside the controllers/ directory with common CRUD methods: index, show, store, update, and destroy. Nested paths are supported.

Create a Model

node-forge make:model user
node-forge make:model admin/user

Creates a model class inside the models/ directory. Nested paths are supported.

Create a Migration

node-forge make:migration create_users_table

Creates a timestamped migration file inside database/migrations/ with up() and down() methods.

Create a Seeder

node-forge make:seeder user
node-forge make:seeder admin/users

Creates a seeder file inside database/seeders/. Nested paths are supported.

Create a View

node-forge make:view users/index
node-forge make:view admin/users/show

Creates an .ejs view file inside the views/ directory.

Create a Route

node-forge make:route user
node-forge make:route admin/user

Creates a route file inside routes/ and auto-registers it in routes/index.js. Generated routes include standard CRUD endpoints.

Create a Full Resource Scaffold

node-forge make:resource user
node-forge make:resource admin/user

Runs multiple CLI generators in sequence to scaffold a full resource. Creates the following files:

  • Controller
  • Service
  • Model
  • Route
  • Seeder
  • Migration

Generated Project Structure

project/
├── cli/
├── config/
│   └── database.js
├── controllers/
├── database/
│   ├── migrations/
│   ├── seeders/
│   ├── migrate.js
│   └── setup.js
├── models/
├── routes/
│   └── index.js
├── services/
├── utils/
│   └── database.js
├── views/
└── .env.example

Example Workflow

# 1. Setup database configuration
node-forge migration

# 2. Generate a full user resource
node-forge make:resource user

# 3. Run migrations
node-forge migrate

# 4. Refresh migrations and seed the database
node-forge migrate:fresh-seed

Notes

  • Nested resource names are supported, such as admin/user.
  • Migration files are timestamped automatically.
  • Route generation auto-registers routes in routes/index.js.
  • Fresh migration disables foreign key checks before rollback.
  • The make:resource script calls make-service.js — ensure it is properly implemented before use, as the current export may throw at runtime if index is not defined.

License

MIT