Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@trisers/cli-node-template

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trisers/cli-node-template

It's a boilerplate for creating Node.js CLI applications.

latest
npmnpm
Version
1.2.0
Version published
Maintainers
1
Created
Source

🚀 Node.js CLI Boilerplate

A powerful CLI tool that generates modular Node.js applications with support for TypeScript/JavaScript, multiple databases, and pre-built modules like authentication.

✨ Features

  • 🔄 Language Support: TypeScript and JavaScript
  • 🗄️ Database Support: MongoDB, MySQL, PostgreSQL
  • 🔐 Authentication System: JWT-based authentication with database-agnostic services
  • 📦 Modular Architecture: Clean separation of concerns
  • ⚡ Zero Configuration: Ready-to-run projects out of the box
  • 🎯 Database-Agnostic: Same API across different databases

📋 Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn
  • Database server (MongoDB, MySQL, or PostgreSQL)

🛠️ Installation

Global Installation

npm install -g node-cli-boilerplate

Local Development

git clone <repository-url>
cd node-cli-boilerplate
npm install
npm link

🎯 Usage

Basic Usage

create-node-app

Interactive Prompts

The CLI will guide you through the following options:

  • Project Name: Enter your project name
  • Language: Choose between TypeScript or JavaScript
  • Database: Select MongoDB, MySQL, PostgreSQL, or None
  • Modules: Choose pre-built modules (Authentication System, None)

Example Session

🚀 Welcome to create-node-app CLI
✔ What is your project name? my-awesome-api
✔ Which language do you want to use? TypeScript
✔ Which database do you want to use? MongoDB
✔ Which modules do you want to include? Authentication System

✅ Project created successfully!

📁 my-awesome-api

💡 Next steps:
cd my-awesome-api
npm install
npm run dev

👉 Copy .env.example to .env and fill in your credentials and values before running the app.

🏗️ Project Structure

Generated Project Structure

my-awesome-api/
├── configs/
│   ├── initServer.ts          # Express server configuration
│   └── mongodb.config.ts      # Database connection (selected DB)
├── constants/
│   ├── codes.ts              # HTTP status codes
│   ├── environment.ts        # Environment variables
│   └── messages.ts           # Response messages
├── controllers/
│   ├── auth.controller.ts    # Authentication endpoints
│   └── example.controller.ts # Example controller
├── middlewares/
│   ├── auth.middleware.ts    # Authentication middleware
│   └── errorHandler.ts       # Global error handler
├── models/                   # MongoDB models (if MongoDB selected)
│   └── User.ts
├── routes/
│   ├── auth.routes.ts        # Authentication routes
│   └── routes.ts             # Main router
├── schemas/                  # SQL schemas (if SQL DB selected)
│   └── users.sql
├── scripts/
│   └── init-schema.js        # Database schema initialization
├── services/
│   └── auth.mongodb.service.ts # Database-specific auth service
├── types/
│   ├── auth.ts              # Authentication type definitions
│   └── common.ts            # Common type definitions
├── utils/
│   ├── auth.utils.ts        # Authentication utilities
│   └── utils.ts             # General utilities
├── .env.example             # Environment variables template
├── index.ts                 # Application entry point
├── package.json             # Project dependencies
└── tsconfig.json            # TypeScript configuration

🗄️ Database Support

MongoDB

  • Model: Mongoose schema with automatic indexing
  • Features: Automatic schema creation, document validation
  • Setup: No additional setup required

PostgreSQL

  • Schema: SQL schema file with UUID primary keys
  • Features: Array support for refresh tokens, proper indexing
  • Setup: Run npm run init-schema to create tables

MySQL

  • Schema: SQL schema file with UUID primary keys
  • Features: JSON support for refresh tokens, proper indexing
  • Setup: Run npm run init-schema to create tables

🚀 Getting Started

1. Create a New Project

create-node-app

2. Navigate to Project

cd your-project-name

3. Install Dependencies

npm install

4. Configure Environment

cp .env.example .env
# Edit .env with your database credentials

5. Initialize Database Schema (SQL databases only)

npm run init-schema

6. Start Development Server

npm run dev

📦 Available Scripts

npm run dev          # Start development server with hot reload
npm run build        # Build for production (TypeScript only)
npm run start        # Start production server
npm run test         # Run tests
npm run init-schema  # Initialize database schema (SQL databases)

🔧 Configuration

TypeScript Configuration

  • Target: ES2022
  • Module: ES Modules
  • Strict Mode: Enabled
  • Path Mapping: Configured for clean imports

Express Configuration

  • CORS: Enabled
  • Body Parser: JSON and URL-encoded
  • Morgan: HTTP request logging
  • Static Files: /uploads directory

Error Handling

  • Global Error Handler: Catches all unhandled errors
  • Custom Error Classes: Structured error responses
  • Validation: Request validation with detailed error messages

🧪 Testing

Running Tests

npm run test

Test Structure

__test__/
├── auth.test.ts     # Authentication tests
├── database.test.ts # Database connection tests
└── utils.test.ts    # Utility function tests

🔒 Security Features

  • Password Hashing: bcrypt with salt rounds
  • JWT Tokens: Secure token-based authentication
  • Refresh Tokens: Automatic token refresh mechanism
  • Input Validation: Request data validation
  • SQL Injection Protection: Parameterized queries
  • CORS Configuration: Cross-origin resource sharing
  • Rate Limiting: Built-in rate limiting (can be extended)

🤝 Contributing

  • Fork the repository
  • Create a feature branch (git checkout -b feature/amazing-feature)
  • Commit your changes (git commit -m 'Add amazing feature')
  • Push to the branch (git push origin feature/amazing-feature)
  • Open a Pull Request

📄 License

This project is licensed under the ISC License.

Made with ❤️ by the Risers Team

FAQs

Package last updated on 21 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts