node-initdb
v2.0.6
Published
A CLI tool to create a folder and file with some code
Downloads
3,991
Readme
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.
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
- MongoDB:
Web Framework:
- Express:
--express
or-e
- Fastify:
--fastify
or-f
- Elysia:
--elysia
or-el
- Express:
Language:
- JavaScript:
--javascript
or-j
- TypeScript:
--typescript
or-t
- JavaScript:
Package Manager:
- Npm:
--npm
or-n
- Bun:
--bun
or-b
- Yarn:
--yarn
or-ya
- Pnpm:
--pnpm
or-pn
- Npm:
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
- MongoDB:
- Web Framework:
- Express:
express
- Fastify:
fastify
- Elysia:
elysia
- Express:
- New Features:
- File Upload:
multer
- JWT Authentication:
jsonwebtoken
- File Upload:
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:
- Email: ashrafchauhan567@gmail.com
- GitHub: @MohamedAshraf701
Support
If you find node-initdb useful, please consider supporting the project: