Skip to content

node-initdb is a CLI tool for initializing database configurations and structures in Node.js projects.

License

Notifications You must be signed in to change notification settings

MohamedAshraf701/node-initdb

Repository files navigation

ashraf704

node-initdb

CLI tool for initializing project configurations and structures in Node.js projects.


node-initdb is a CLI tool for initializing project configurations and structures in Node.js projects. It now requires you to select a database, a web framework, a language (JavaScript or TypeScript), and a package manager for the tool to work. In addition to setting up your chosen database and framework, node-initdb now supports file upload functionality and JWT-based authentication.

Node InitDB Plugin Demo

Installation

Install node-initdb globally using npm:

npm install -g node-initdb

Usage

Navigate to your project directory and run node-initdb with the appropriate options. You must choose one option each for:

  • Database:

    • MongoDB: --mongo or -m
    • Sequelize: --seque or -s
  • Web Framework:

    • Express: --express or -e
    • Fastify: --fastify or -f
    • Elysia: --elysia or -el
  • Language:

    • JavaScript: --javascript or -j
    • TypeScript: --typescript or -t
  • Package Manager:

    • Npm: --npm or -n
    • Bun: --bun or -b
    • Yarn: --yarn or -ya
    • Pnpm: --pnpm or -pn

Important: All four categories (database, framework, language, and package manager) are required. If any one is missing, node-initdb will not run.

Optionally, you can add --yes (or -y) to skip interactive prompts and use default values.

Examples

  • MongoDB, Express, and TypeScript with npm:

    node-initdb --mongo --express --typescript --npm
    # or shorthand:
    node-initdb -m -e -t -n
  • Sequelize, Fastify, and JavaScript with bun:

    node-initdb --seque --fastify --javascript --bun
    # or shorthand:
    node-initdb -s -f -j -b
  • Sequelize, Elysia, and JavaScript with yarn:

    node-initdb --seque --elysia --javascript --yarn
    # or shorthand:
    node-initdb -s -el -j -ya

Add Module Task

To add a new module using node-add, run:

node-add <moduleName> [options]

Replace <moduleName> with your desired module name. Use the same options for database, framework, language, and package manager:

  • Database: -m / --mongo, -s / --seque
  • Framework: -e / --express, -f / --fastify, -el / --elysia
  • Language: -j / --javascript, -t / --typescript
  • Package Manager: -n / --npm, -b / --bun, -ya / --yarn, -pn / --pnpm

Example

node-add "user" -m -e -t

Folder Structure

After running node-initdb, your project will have the following structure:

- config/
- Controllers/
- Routes/
- Models/
- Middleware/
- uploads/
- Utils/

Files Created

node-initdb creates essential files such as controllers, routes, models, configuration files, and middleware. In addition, the setup includes:

  • File Upload: Pre-configured file upload functionality.
  • JWT Authentication: Setup for JWT-based authentication.

Dependencies

Depending on your chosen configuration, node-initdb installs the following dependencies:

  • Database:
    • MongoDB: mongoose
    • Sequelize: sequelize, mysql2
  • Web Framework:
    • Express: express
    • Fastify: fastify
    • Elysia: elysia
  • New Features:
    • File Upload: multer
    • JWT Authentication: jsonwebtoken

Contributing

Contributions are welcome! Fork the repository, implement your changes, and submit a pull request. Please follow the existing coding style and guidelines.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Get in Touch

For questions or support, feel free to reach out:

Support

If you find node-initdb useful, please consider supporting the project:

ashraf704

About

node-initdb is a CLI tool for initializing database configurations and structures in Node.js projects.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •