create-express-backend-setup v1.0.3
Express App Generator
Welcome to the Express App Generator! This tool is designed to help you quickly generate a fully structured and well-organized Express.js app. It guides you through a series of questions to customize your app setup based on your preferences. Whether you're building a simple Express API or a more advanced full-stack app, this generator can help you get started in just a few minutes. Features
Choose between JavaScript or TypeScript for your project.
Option to integrate MongoDB for database management.
Enable GraphQL for advanced data querying.
Add CORS support for cross-origin requests.
Set up a basic error handler for better error management.
Configure a .env file to manage environment variables.
Integrate Morgan for HTTP request logging.
Option to use Docker for containerized deployment.
Enable ESLint for code linting to maintain a clean and consistent codebase.
Set up Path Aliases (like @/src) for TypeScript projects.
Automatically install project dependencies.
Option to auto-start the server (coming soon!).
Table of Contents
Installation
How It Works
Project Setup Options
Directory Structure
License
Installation
- Install dependencies
Run the following command to install all the necessary dependencies:
npm install
- Run the generator
After installation, you can start the generator by running the following command:
node index.js
This will trigger the question prompts in your terminal, where you can customize your project based on your needs. How It Works
Once you run the generator, you'll be prompted with a series of questions to customize your app. Here’s a breakdown of each question: Project Setup Options
Project Name
Question: "Enter your project name:"
Description: Choose a name for your project. This will be the folder name and the main project identifier.
Default: myapp
Preferred Language
Question: "Select your preferred language:"
Description: Choose between JavaScript and TypeScript. TypeScript provides strong typing and better development experience, while JavaScript is more lightweight.
Choices: JavaScript, TypeScript
Default: TypeScript
Use MongoDB
Question: "Do you want to use MongoDB?"
Description: MongoDB is a popular NoSQL database that is highly flexible and scalable. Choose Yes to integrate it into your project.
Choices: Yes, No
Default: No
Use GraphQL
Question: "Do you want to use GraphQL?"
Description: GraphQL is a query language for APIs and a runtime for executing those queries. Select Yes to include GraphQL support in your project.
Choices: Yes, No
Default: No
Enable CORS
Question: "Do you want to enable CORS?"
Description: CORS (Cross-Origin Resource Sharing) allows your app to communicate with different domains. It is particularly useful when your backend is separated from your frontend.
Choices: Yes, No
Default: No
Use Basic Error Handler
Question: "Do you want to use a basic error handler?"
Description: Choose Yes to include a basic error-handling middleware in your app.
Choices: Yes, No
Default: Yes
Use .env File
Question: "Do you want to use an environment file?"
Description: The .env file helps you manage your environment variables (like database URLs, secret keys, etc.) outside your codebase. It’s highly recommended to use one for security and flexibility.
Choices: Yes, No
Default: Yes
Use Morgan for Logging
Question: "Do you want to use morgan for logging?"
Description: Morgan is an HTTP request logger middleware. It helps you track requests and responses in your app for debugging and monitoring.
Choices: Yes, No
Default: Yes
Use Docker
Question: "Do you want to use Docker for deployment?"
Description: Docker helps you create containerized applications, making deployment easier and more portable.
Choices: Yes, No
Default: Yes
Use ESLint for Code Linting
Question: "Do you want to use ESLint for code linting?"
Description: ESLint helps maintain code quality by checking for syntax errors and enforcing coding standards.
Choices: Yes, No
Default: Yes
Use Path Alias
Question: "Do you want to set @/ as the src path alias?"
Description: This feature is available if you're using TypeScript. It allows you to use @/ as an alias for the src directory, making your imports cleaner and more maintainable.
Choices: Yes, No
Default: Yes
When: Only when TypeScript is selected.
Auto-install Dependencies
Question: "Do you want to auto-install dependencies?"
Description: This option automatically installs the necessary dependencies as soon as the project is generated.
Choices: Yes, No
Default: Yes
Directory Structure
After the generator completes, your project will be structured as follows:
myapp/ # Root project folder ├── src/ # Source code folder │ ├── controllers/ # Controllers for handling requests │ ├── models/ # MongoDB models (if MongoDB is selected) │ ├── routes/ # Route definitions │ ├── middlewares/ # Middlewares like error handling, CORS, etc. │ ├── services/ # Logic for interacting with the database │ └── index.ts # Entry point (main app setup) ├── .env # Environment variables (if selected) ├── Dockerfile # Docker setup (if selected) ├── .eslintrc.json # ESLint configuration (if selected) ├── tsconfig.json # TypeScript configuration (if TypeScript is selected) ├── package.json # Project dependencies and scripts └── README.md # Project documentation
License
This project is licensed under the MIT License - see the LICENSE file for details. Contribution
Contributions are welcome! Feel free to open issues or pull requests on GitHub. Acknowledgements
Express.js - The web framework that powers your app.
MongoDB - A NoSQL database that can be easily integrated into Express apps.
GraphQL - A modern query language for your APIs.
Docker - Containerizing your app for seamless deployment.
ESLint - A linter for identifying and fixing problems in your JavaScript/TypeScript code.
Final Thoughts
Thank you for using the Express App Generator! With this generator, you’ll be able to set up and deploy your project quickly and efficiently, while having full control over the setup process. Enjoy building your Express app!