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 🙏

© 2025 – Pkg Stats / Ryan Hefner

backtool

v1.2.0

Published

This tool cli creates a backend setup with express js mongodb or postgresql

Readme

backtool

BackTool

A CLI tool to generate backend structures for Node.js applications with support for multiple databases and a visually appealing user interface.

Overview

BackTool simplifies the process of setting up a Node.js backend by generating a complete project structure, including a server entry point, models, database configuration, controllers, routes, middleware, and a customized package.json. It supports MongoDB, PostgreSQL, MySQL, and SQLite, allowing developers to quickly scaffold a backend tailored to their preferred database.

Features

  • Database Support: Generates configurations and models for MongoDB, PostgreSQL, MySQL, and SQLite.
  • Language Support: Generates projects in both JavaScript and TypeScript with proper configurations.
  • Interactive Prompts: Uses inquirer for styled, user-friendly prompts with custom prefixes and validation.
  • Visual Feedback: Includes an ASCII art banner (figlet), colored output (chalk), and progress spinners (ora).
  • Non-Interactive Mode: Supports command-line arguments for automation (e.g., backtool --project my-app --database MongoDB).
  • Complete Backend Structure: Creates server.js, package.json, and directories for models, config, controllers, routes, and middleware.
  • Customized package.json: Generates a package.json with the project name, scripts (start, dev), and dependencies.
  • Automatic Package Installation: Installs required dependencies (e.g., express, mongoose, pg, mysql2, sqlite3) and nodemon as a dev dependency.
  • Git Initialization: Automatically initializes a Git repository in the generated project with proper .gitignore setup.
  • Environment Configuration: Includes .env.example template that gets copied to .env for easy environment setup.
  • File Overwrite Protection: Prompts users before overwriting existing files (e.g., server.js, package.json, model files).
  • Extensible: Easily add new databases or structure components by updating the template folder.

Installation

Install BackTool globally to use it from any directory:

npm install -g backtool

Alternatively, clone the repository and link it locally:

git clone https://github.com/Amanbig/backtool.git
cd backtool
npm install
npm link

Usage

Interactive Mode

Run BackTool without arguments to use interactive prompts:

backtool

or directly using:

npx backtool@latest

This will display an ASCII banner and prompt for:

  • Project name (e.g., my-app)
  • Database choice (MongoDB, MySQL, PostgreSQL, or SQLite)

Non-Interactive Mode

Specify options directly to skip prompts:

backtool --project my-app --database MongoDB

Options

  • -p, --project <name>: Specify the project name (default: my-app).
  • -d, --database <type>: Specify the database (MongoDB, MySQL, PostgreSQL, SQLite).
  • -l, --language <type>: Specify the language (JavaScript, TypeScript).
  • -f, --force: Force overwrite of existing files without prompting.
  • -u, --uri <uri>: Specify database connection URI.
  • -v, --version: Display the version number.
  • -h, --help: Show help information.

Generated Structure

Running BackTool creates one of the following directory structures based on the chosen language:

JavaScript Structure

my-app/
├── server.js
├── package.json
├── .env
├── .gitignore
├── config/
│   └── database.js
├── models/
│   └── user.<database>.js
├── controllers/
│   └── authController.js
├── routes/
│   └── auth.js
├── middleware/
│   └── auth.js
├── node_modules/
└── .git/

TypeScript Structure

my-app/
├── server.ts
├── package.json
├── tsconfig.json
├── .env
├── .gitignore
├── src/
│   ├── config/
│   │   └── database.ts
│   ├── models/
│   │   └── user.<database>.ts
│   ├── controllers/
│   │   └── authController.ts
│   ├── routes/
│   │   └── auth.ts
│   ├── middleware/
│   │   └── auth.ts
│   └── types/
│       └── express.d.ts
├── dist/           # Compiled JavaScript
├── node_modules/
└── .git/
  • server.[js|ts]: Entry point for the Node.js application, setting up the Express server and routes.
  • package.json: Includes project configuration, scripts, and dependencies. For TypeScript projects, includes additional scripts for building and type checking.
  • tsconfig.json: (TypeScript only) TypeScript compiler configuration.
  • config/database.[js|ts]: Database connection and table initialization.
  • models/: Database models with database-specific implementations.
  • controllers/: Request handling logic including authentication.
  • routes/: API route definitions.
  • middleware/: Custom middleware (e.g., authentication).
  • types/: (TypeScript only) Type definitions and declarations.
  • dist/: (TypeScript only) Compiled JavaScript output.

The users table/model includes fields: id, username, email, password, and created_at.

Running the Application

After generating the project, navigate to the project directory and run:

# For JavaScript projects
npm start

# For TypeScript projects
npm start        # Runs with ts-node
npm run build    # Compiles TypeScript to JavaScript
npm run start:prod  # Runs the compiled JavaScript

For development with auto-restart on file changes:

npm run dev     # Works for both JavaScript and TypeScript

Supported Databases

  • MongoDB: Uses mongoose for schema-based modeling.
  • PostgreSQL: Uses pg with a connection pool and SQL queries.
  • MySQL: Uses mysql2 with a promise-based connection pool.
  • SQLite: Uses sqlite3 and sqlite for lightweight, file-based storage.

Dependencies

BackTool installs the following dependencies in the generated project:

Common Dependencies

  • Core Dependencies: express, dotenv, cors, jsonwebtoken
  • Database-specific Dependencies:
    • MongoDB: mongoose, bcryptjs
    • PostgreSQL: pg, bcryptjs
    • MySQL: mysql2, bcryptjs
    • SQLite: sqlite3, bcryptjs

Development Dependencies

  • Common: nodemon
  • TypeScript-specific (when TypeScript is selected):
    • typescript
    • ts-node
    • @types/node
    • @types/express
    • @types/cors
    • @types/jsonwebtoken
    • @types/bcryptjs
    • Database-specific types (e.g., @types/mongoose, @types/pg)

Development

To contribute or modify BackTool:

  1. Clone the repository:
    git clone https://github.com/Amanbig/backtool.git
  2. Install dependencies:
    npm install
  3. Update the backtool_folder directory with custom templates (e.g., server.js, models).
  4. Test locally:
    npm link
    backtool --project test-app --database SQLite

Buy Me a Coffee

License

MIT License

Contact

For issues or feature requests, open a ticket on the GitHub repository.