UNPKG

create-nodejs-app-template

Version:

[![npm version](https://img.shields.io/npm/v/create-nodejs-app-template.svg)](https://www.npmjs.com/package/create-nodejs-app-template) [![license](https://img.shields.io/npm/l/create-nodejs-app-template.svg)](https://github.com/umairabbas786/create-nodej

212 lines (143 loc) 4.87 kB
# create-nodejs-app-template [![npm version](https://img.shields.io/npm/v/create-nodejs-app-template.svg)](https://www.npmjs.com/package/create-nodejs-app-template) [![license](https://img.shields.io/npm/l/create-nodejs-app-template.svg)](https://github.com/umairabbas786/create-nodejs-app-template/blob/main/LICENSE) 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: ```bash npm install -g create-nodejs-app-template ``` Or, use without installation via NPX: ```bash npx create-nodejs-app-template myProjectName ``` --- ## Usage To create a new Node.js project, run: ```bash npx create-nodejs-app-template myNewProject ``` ### **Options 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.js ``` --- ## Commands After creating the project, navigate to the directory and run: ```bash cd mynewproject npm install npm run dev ``` **Available 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: ```env PORT=5000 MONGO_URI=mongodb://localhost:27017/myapp JWT_SECRET=mysecretkey MAIL_SERVICE=gmail MAIL_USER=your-email@gmail.com MAIL_PASS=your-password CLOUDINARY_CLOUD_NAME=your-cloud-name CLOUDINARY_API_KEY=your-api-key CLOUDINARY_API_SECRET=your-api-secret ``` --- ## API 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: 1. Ensure you're using **Node.js v14+**. 2. Run the command without spaces in the project name. 3. Delete any previously created project folder before re-running the command: ```bash rm -rf mynewproject ``` 4. Clear the NPM cache and try again: ```bash npm cache clean --force ``` --- ## Contributing Contributions are welcome! Please follow these steps: 1. Fork the repository on GitHub. 2. Clone your fork locally. 3. Create a new branch (`git checkout -b feature-branch`). 4. Commit your changes (`git commit -m "Add feature"`). 5. Push to your fork and create a pull request. --- ## License This project is licensed under the **ISC License**. See the [LICENSE](LICENSE) file for details. --- ## Support If you find any issues or have suggestions for improvement, feel free to open an issue on GitHub: [GitHub Issues](https://github.com/umairabbas786/create-nodejs-app-template/issues) --- ## Author Developed with ❤️ by **CODEFLAMME** --- ## Related Projects If you like this project, check out similar boilerplates: - [express-generator](https://www.npmjs.com/package/express-generator) - [create-express-app](https://www.npmjs.com/package/create-express-app) --- ## Stay Connected Follow me on: - GitHub: [umairabbas786](https://github.com/umairabbas786) - LinkedIn: [LinkedIn Profile](https://www.linkedin.com/in/your-profile)