Skip to content

abdrahmanES1/express-api-initializer

Repository files navigation

Express API Initializer

Express API Initializer is a tool designed to streamline the process of generating Express.js applications.

Installation

Ensure you have node.js) installed, then install express-api-initializer globally using npm:

npm install -g express-api-initializer

To create a new project, run:

express-initializer new <app-name>

Your app structure will be initialized as follows:

📦 app
 ┣ 📂 config
 ┃ ┗ 📜 database.config.js
 ┣ 📂 src
 ┃ ┣ 📂 controllers
 ┃ ┃ ┗ 📜 users.controller.js
 ┃ ┣ 📂 middlewares
 ┃ ┃ ┣ 📜 error.middleware.js
 ┃ ┃ ┣ 📜 users.middleware.js
 ┃ ┃ ┗ 📜 validationMiddleware.middleware.js
 ┃ ┣ 📂 models
 ┃ ┃ ┗ 📜 users.model.js
 ┃ ┣ 📂 schemas
 ┃ ┃ ┗ 📜 users.schema.js
 ┃ ┣ 📂 routes
 ┃ ┃ ┗ 📜 users.route.js
 ┃ ┣ 📂 utils
 ┃ ┃ ┗ 📜 errorResponse.js
 ┃ ┗ 📜 app.js
 ┣ .env.example
 ┣ .env
 ┣ 📜 index.js
 ┗ 📜 package.json

To start the app, navigate to the project directory and run:

node index.js

## Resource Generation

Generate resources using plural nouns:

```bash
express-initializer g resource <resource-name>

Controller Generation

Generate controllers using:

express-initializer g controller <controller-name>

Model Generation

Generate models using:

express-initializer g model <model-name>

Validation Schema Generation

Generate schema using:

express-initializer g schema <model-name>

Route Generation

Generate routes using:

express-initializer g route <route-name>

Middleware Generation

Generate middleware using:

express-initializer g middleware <middleware-name>

Configuration Generation

Generate configs using:

express-initializer g config <config-name>

Feel free to use these commands to efficiently scaffold and organize your Express.js applications.