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 🙏

© 2024 – Pkg Stats / Ryan Hefner

express-cli-builder

v1.1.4

Published

It provides an easy way to generate essential components such as models, routes, controllers, middlewares, and resources with boilerplate templates, streamlining project setup and organization.

Downloads

49

Readme

Express CLI

A command-line tool for generating Express application components

Description

Express CLI is a powerful command-line tool that streamlines the development of Express.js applications. It provides a straightforward way to generate essential components like models, routes, controllers, middlewares, and resources, complete with boilerplate templates. With the express init command, users can easily set up a basic Express app template with customizable options for TypeScript or JavaScript, and select their preferred database (MySQL, MongoDB, or skip database setup entirely).

When a database is selected, the CLI automatically configures the database connection and generates a .env file with the required environment variables, such as the connection URL for MongoDB, or the database name, user, and password for MySQL. Even if users opt to skip database configuration, the CLI ensures the project remains clean and organized. This allows developers to focus more on building features and less on repetitive tasks, while still offering flexibility for future project scaling.

To make navigation easier, the express --help command provides users with a list of all available commands, each with a short description of its functionality. This makes it simple to explore and use the CLI’s features, allowing developers to focus more on building features and reducing repetitive tasks.

Installation

Note: To access the express-cli-builder commands from anywhere on your system, it is recommended to install the package globally using the following command:

npm install -g express-cli-builder

This will allow you to use the express command in any directory without needing to install it locally for every project.

Usage

Once installed, you can use the command line to generate different components for your Express.js app.

Initialize a Basic App Template

To initialize a basic Express app template, use the following command:

express init

This command will prompt you with the following questions:

  1. Would you like to use TypeScript or JavaScript?
  2. Which database would you like to use: MySQL or MongoDB?
  3. Do you want to use a src folder?

Based on your answers, the appropriate packages (including cors, dotenv, and body-parser) will be installed, along with TypeScript types if you choose TypeScript.

List of All Commands

To view all available commands, use the following command:

express --help

Tip: Executing this command will display a list of all the commands along with their descriptions.

Create a Model

To generate a model, use the following command:

express create:model <model-name>

This command will create a model in the models folder. If the folder doesn’t exist, it will be created automatically.

Create a Controller

To generate a controller, use the following command:

express create:controller <controller-name>

This will create a controller in the controllers folder.

Create a Route

To generate a route, use the following command:

express create:route <route-name>

This will create a route in the routes folder.

Create a Middleware

To generate a middleware, use the following command:

express create:middleware <middleware-name>

This will create a middleware in the middlewares folder.

Create a Resource

The resource command will create a model, route, and controller with boilerplate code:

express create:resource <resource-name>

This will create:

  • The model in the models folder.
  • The controller in the controllers folder.
  • The route in the routes folder.

Features

  • Initialize Basic App Template: Use the express init command to set up a basic Express app with a customizable folder structure.
  • Generate Models: Quickly create Mongoose models with predefined schema templates.
  • Create Routes: Easily set up route files linked to their corresponding controllers.
  • Build Controllers: Generate controller files to manage application logic and data interactions.
  • Set Up Middlewares: Create reusable middleware functions for enhanced application functionality.
  • Resource Creation: Create a full set of model, route, and controller files for rapid development.
  • Database Configuration: Automatically configure database connections and generate a .env file with necessary environment variables for MongoDB and MySQL, or skip database setup if desired.
  • Help Command: Use the express --help command to view all available commands with brief descriptions.

Benefits

  • Consistent Structure: Ensures a standardized file structure for better organization and maintainability.
  • Time-Saving: Reduces repetitive boilerplate code, allowing developers to focus on building features.
  • Flexibility: Customize templates to fit project needs, enhancing code reusability.
  • Streamlined Setup: Simplifies the initial setup process with automated configurations and clear command documentation, making it easier for developers to start new projects.