e-generator
v1.1.7
Published
A CLI to generate a Node.js, Express, TypeScript, Docker and MongoDB backend.
Downloads
35
Maintainers
Readme
e-generator
e-generator is a command-line interface (CLI) tool that allows you to quickly generate a complete backend application based on Node.js, Express.js, TypeScript, Docker, MongoDB, and Mongoose.
This package automates the setup process, providing you with a clean and ready-to-develop project structure, including essential configuration files and an API example.
Index
- Installation
- Usage
- Features
- Project Structure
- Contributing
- License
Installation
To use e-generator, you can install it globally via npm:
npm install -g e-generatorAlternatively, you can use it directly without installation using npx:
npx e-generator <project_name>Usage
To generate a new project, run the following command:
e-generator <project_name>This will create a new directory called <project_name> with the initial project structure and files.
After the generation is complete, you can navigate into the project directory:
- Change into the project directory:
cd <project_name>- Install the project dependencies:
npm install- Configure the database
# Create a .env file in the root of your project
touch .env
# Add your MongoDB connection string to the .env file
echo "MONGODB_URI=mongodb://localhost:27017/<your_database_name>" > .envReplace the MONGODB_URI value with your actual MongoDB connection string.
- Start the development server
- For development:
npm run dev- For production:
npm run build
npm startDocker
If you prefer to use Docker, you can use the e-generator tool by building an image and running it as a container. This is useful for users who don't want to install Node.js and npm globally.
- Build the Docker image
From the root of the
e-generatordirectory, run the following command to build the image:
docker build -t e-generator .- Generate a new project To generate a new project using the Docker container, run the following command:
docker run --rm -v $(pwd):/app -w /app e-generator <project_name>This will create a new <project_name> directory in your current working directory.
- Run the generated project
To run the backend application generated by e-generator inside a Docker container, you can follow these steps:
Navigate to the newly created project directory: cd <project_name>
Create a .env file with your database URI: echo "MONGODB_URI=mongodb://host.docker.internal:27017/<your_database_name>" > .env
Build a new Docker image for your project: docker build -t <your_project_name> .
Run the container: docker run -p 3000:3000 <your_project_name>
Features
- Automatic Setup: Quickly generates a complete backend application with sensible defaults.
- TypeScript Support: Built with TypeScript for better development experience and type safety.
- MongoDB Integration: Comes with Mongoose setup for easy MongoDB interactions.
- Configurable: Easily customize the generated project to fit your needs.
Project Structure
<project_name>
├── dist/
├── .env
├── .gitignore
├── src/
│ ├── config/
│ ├── controllers/
│ ├── models/
│ ├── routes/
│ └── utils/
├── package.json
├── tsconfig.json
└── README.md
Contributing
We welcome contributions to e-generator! If you'd like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them with descriptive messages.
- Push your changes to your forked repository.
- Submit a pull request detailing your changes.
Please ensure that your code adheres to the project's coding standards and includes appropriate tests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
