create-nodejs-app-template
v1.0.9
Published
[](https://www.npmjs.com/package/create-nodejs-app-template) [](https://github.com/umairabbas786/create-nodej
Readme
create-nodejs-app-template
A CLI tool to quickly scaffold a Node.js project with a predefined structure and essential dependencies.
Features
- 📦 Pre-configured Node.js project structure (MVC pattern)
- 🔑 Authentication setup (JWT, bcrypt)
- 📧 Nodemailer integration for emails
- ☁️ Cloudinary integration for image uploads
- ✅ Form validation with express-validator
- 🌐 CORS and dotenv setup
- 🚀 Nodemon for easy development
Installation
To install the package globally via NPM, run:
npm install -g create-nodejs-app-templateOr, use without installation via NPX:
npx create-nodejs-app-template myProjectNameUsage
To create a new Node.js project, run:
npx create-nodejs-app-template myNewProjectOptions and Rules:
- The project name must be in camelCase (e.g.,
myProjectName). - Spaces and special characters are not allowed.
- The project name will be converted to lowercase in
package.json.
Project Structure
After successful setup, the project will have the following structure:
mynewproject/
├── src/
│ ├── controllers/
│ ├── routes/
│ ├── services/
│ ├── models/
│ ├── config/
│ ├── index.js
├── .env.example
├── .gitignore
├── package.json
├── README.md
├── app.js
├── server.js
└── config.jsCommands
After creating the project, navigate to the directory and run:
cd mynewproject
npm install
npm run devAvailable scripts:
npm start– Start the server.npm run dev– Run the server in development mode using Nodemon.
Environment Variables
Create a .env file from .env.example and configure the required environment variables:
PORT=5000
MONGO_URI=mongodb://localhost:27017/myapp
JWT_SECRET=mysecretkey
MAIL_SERVICE=gmail
[email protected]
MAIL_PASS=your-password
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secretAPI Endpoints
User Routes
| Method | Endpoint | Description | |--------|-------------|---------------------| | GET | /api/users | Get all users | | POST | /api/users | Create a new user |
Utility Routes
| Method | Endpoint | Description | |--------|------------------|--------------------------| | POST | /api/utils/upload | Upload an image to Cloudinary | | POST | /api/utils/send-email | Send an email via Nodemailer |
Dependencies
The template comes pre-installed with the following key dependencies:
- Express – Web framework for Node.js
- Mongoose – MongoDB ODM
- JWT – JSON Web Token authentication
- BcryptJS – Secure password hashing
- Cloudinary – Cloud image storage
- Multer – File uploads
- Nodemailer – Email sending service
- Dotenv – Environment variable management
- CORS – Cross-origin resource sharing
Troubleshooting
If you encounter any issues while creating the project, try the following:
Ensure you're using Node.js v14+.
Run the command without spaces in the project name.
Delete any previously created project folder before re-running the command:
rm -rf mynewprojectClear the NPM cache and try again:
npm cache clean --force
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository on GitHub.
- Clone your fork locally.
- Create a new branch (
git checkout -b feature-branch). - Commit your changes (
git commit -m "Add feature"). - Push to your fork and create a pull request.
License
This project is licensed under the ISC License. See the LICENSE file for details.
Support
If you find any issues or have suggestions for improvement, feel free to open an issue on GitHub:
Author
Developed with ❤️ by CODEFLAMME
Related Projects
If you like this project, check out similar boilerplates:
Stay Connected
Follow me on:
- GitHub: umairabbas786
- LinkedIn: LinkedIn Profile
