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

@yoirchalk/express-mongoose-cli-tool

v1.2.5

Published

A CLI tool to generate boilerplate code for express routers and mongoose models with joi validation.

Downloads

9

Readme

express-boilerplate-cli-tool

A CLI tool to generate boilerplate code for express routers and mongoose models with joi validation.

Contents

Not sure why links aren't working on npmjs.com. They work in GitHub

Features

  • Automatically generates Mongoose models with Joi validation.
  • Generates Express routes.
  • Handles both singular and plural forms.
  • Places generated files in appropriate models and routes directories.
  • Creates models or routes folders in the root directory if they do not exist.
  • New features in 1.1.0
    • Ability to set file as template for boilerplate using -c flag
  • Next update
    • -r tag to restore default boilerplate template
  • Future updates
    • More comprehensive native support for different express stacks
      • mySQL
      • postgreSQL
    • Database initialization boilerplate code
    • Ability to set stack flag once and generate boileplate based on chosen stack every time without needing to pass flag.

Installation

Run the following command to install as a dev dependency:

npm install @yoirchalk/express-mongoose-cli-tool --save-dev

Usage

Generating boilerplate code

This package provides a CLI tool for generating boilerplate code for your project. The command syntax is:

generate_bp <type> <name>

where:

  • <type> is the type of boilerplate you want to generate. It can be

    • model for generating a mongoose model with joi validation
    • route for generating an express route
    • both to generate both a route and a model
  • name is the name of the model or route you want to generate (e.g 'User', 'Products')

The program is case-insensitive and automatically handles both singular and plural forms.

The program places files in an approprite models/routes folder and will create the folder in root folder if it doesn't exist.

Usage Examples

  • generate model
generate_bp model Appartment
  • generate route
generate_bp route houses
  • generate both a route and a model
generate_bp both Locations
  • view help
generate_bp -h
generate_bp --help

Setting file as boilerplate template

Command syntax is

generate_bp <type> -c <file>

where

  • <type> is type of boilerplate to set either;
    • <model> or
    • <route>
  • <file> is the .js file which contains a constant called template which is set to a template string which contains template boilerplate code

Usage example

generate_pb route -c template.js

and an example of template.js content:

let template = `
const express = require('express')
const mysql = require('mysql2')

app.get('/${pluralName}', (req, res) => {
  const query = 'SELECT * FROM ${pluralName}';
  
  db.query(query, (err, ${pluralName}$) => {
    if (err) {
      console.error('Error fetching ${pluralName}:', err);
      res.status(500).json({ error: 'Failed to fetch ${pluralName}' });
      return;
    }
    res.send(${pluralName});
  });
});
`

Make sure to include necessary import statements.

Constant must end with semicolon ;

Must use let keyword and not const

Contribution and Feedback

Contributions, bug reports and suggestions are very welcome! Here's how you can help improve this package;

Reporting bugs and suggesting features

If you find a bug or have an idea for an improvment please

  • open an issue in git hub or
  • contact me directly
    • be sure to add package name in subject line. No need for @yoirchalk
    • if link doesnt work right click and click on 'copy email adress'

Contributing via GitHub

  • Visit repository at https://github.com/yoirchalk1995/express-boilerplate-cli-tool
  • Fork the repository by clicking fork at top right of page
  • Clone youre fork
    git clone https://github.com/YOUR_USERNAME/YOUR_FORK.git
  • Create a new branch for your feature or fix
    git checkout -b feature-name
  • Make changes and commit them
    git commit -m "Add new feature"
  • Push your changes
    git push origin feature-name
  • Submit a push request. I'll review it asap