ez-app-builder v2.3.6
ez-app-builder
ez-app-builder is a Node.js package designed to streamline the process of setting up full-stack applications. It automates the creation of directory structures and offers an interactive interface to install essential npm packages. With ez-app-builder, developers can quickly initialize their projects, saving time and effort in the setup phase.
## Features
- **Automated Directory Structure**: Quickly set up backend and frontend directories with a simple command.
- **Interactive Package Installation**: Choose from a list of essential npm packages to install for your project.
- **Supports Full-Stack Applications**: Build both backend and frontend parts of your application effortlessly.
- **Saves Time and Effort**: Eliminate the manual setup process and get started with your project right away.
## Installation
You can install `ez-app-builder globally` using npm:
```bash
`npm install -g ez-app-builder`
```
Usage
Once installed, you can use ez-app-builder commands to create your projects:
- To build your project:
build
- To build the backend:
build-backend
- To build the frontend:
build-frontend
Follow the prompts to customize your project setup and package installations.
How to Use
Creating a Full-Stack Project
To create a full-stack project, follow these steps:
- Run
build
in your terminal. - Enter a name for your project and choose the packages you want to install.
- The script will create backend and frontend directories with the specified name and install the chosen packages in each directory.
- You can then customize the backend and frontend as needed for your project.
Creating Backend Only
To create a backend-only project, follow these steps:
- Run
build-backend
in your terminal. - Enter a name for your backend directory and choose the packages you want to install.
- The script will create a backend directory with the specified name and install the chosen packages.
- You can then customize the backend for your project.
Creating Frontend Only
To create a frontend-only project, follow these steps:
- Run
build-frontend
in your terminal. - Enter a name for your frontend directory and choose the packages you want to install.
- The script will create a frontend directory with the specified name and install the chosen packages.
- You can then customize the frontend for your project.
Customization
- Project Name: You can customize the name of your project by entering a different name when prompted.
- Packages: Choose the npm packages you want to install for your project. Select from the list of available packages or enter custom package names.
Setup for MongoDB Configuration
To set up a MongoDB configuration and connect to a MongoDB database in your backend project, follow these steps:
Ensure that
mongoose
is included as part of your project dependencies. If not, you can install it usingnpm install mongoose
in your backend directory.Update your main backend file (e.g.,
index.js
orserver.js
) to import and call theconnectDB
function:
import express from "express";
import mongoose from "mongoose";
const app = express();
// MongoDB connection
mongoose
.connect(process.env.MONGODB_URI || "mongodb://localhost:27017/mydatabase")
.then(() => console.log("MongoDB connected"))
.catch((err) => console.error("MongoDB connection error:", err));
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
Setup for Main File in Backend
The main file in the backend directory is typically named index.js
or server.js
. You can customize this file to set up your backend server using Express, Koa, or any other framework of your choice. Here's an example of setting up a basic Express server in index.js
:
import express from "express";
const app = express();
app.get("/", (req, res) => {
res.send("Hello, world!");
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
You can further customize this file to add routes, middleware, database connections, etc., based on your project requirements.