An open API service indexing awesome lists of open source software.

https://github.com/backendexpert/automate-backend-fullstack

automate backend fullstack with MVC (NPM Package)
https://github.com/backendexpert/automate-backend-fullstack

fullstack-development javascript mern-stack npm npm-package

Last synced: 5 months ago
JSON representation

automate backend fullstack with MVC (NPM Package)

Awesome Lists containing this project

README

          

# Automate Backend MVC for FullStack Projects





- `automate-backend-fullstack` is an npm package that helps you quickly set up a MongoDB model, Controller and Route in a Node.js MVC backend using the Mongoose ORM. This CLI tool allows you to specify model details, including field types, uniqueness, requirements, and default values, creating a ready-to-use Mongoose schema.

## Features

- Interactive CLI: Prompts for model name, number of fields, and details for each field.
- Flexible Field Options: Supports field configurations including type, unique, required, and default value.
- Automatic Model Generation: Creates a Mongoose model file in a structured format. Avoids Redundant Model Creation:
- Avoids Redundant Model Creation: Checks if a model with the specified name already exists and prompts to confirm overwriting, saving you from recreating existing models.

- About Controller : This npm package helps to create Controllers after create models. According to this Controller created using given name for model

- About Route : This npm package helps to create Routes after create models and Controllers. According to this Route created using given name for model

## Installation

- To use this package as a global CLI tool, install it using:

```bash

npm install -g automate-backend-fullstack

```

## Usage

- To create a new model, simply run:

```bash

npx create-mvc-fullstack

```

## Step-by-Step Process

- Run the Command: After running `npx create-mvc-fullstack` you’ll be prompted for the model details.
- Specify the Model Name: Enter the name for your model (e.g., User, Product). If a model with this name already exists, you’ll be prompted to overwrite it or skip creation.
- Define Field Count: Specify the number of fields the model will have.
- Enter Field Details: For each field, you’ll be prompted for:
- - Field Name: Name of the field (e.g., email, username).
- - Field Type: Data type of the field (e.g., String, Number).
- - Unique: Whether the field should be unique (true or false).
- - Required: Whether the field is required (true or false).
- - Default Value: Optional default value for the field (leave blank if not required).

- After Model Create then you can create Controller
- - after creating of model it automatically ask to create Controller and Route using given name for model

## Example

- If you specify a model name as `User` with two fields (email and username), the generated schema file will look like this:

```js

const mongoose = require("mongoose");

const UserSchema = new mongoose.Schema({
email: {
type: String,
unique: true,
required: true
},
username: {
type: String,
required: true
}
});

module.exports = mongoose.model("User", UserSchema);

```

- Example Controller

```js

// this user model can be changed
const user = require("../models/user");

// Controller name can be changed
const userController = {
// body of controller goese here
// create methods in here that you need to create
};

module.exports = userController;

```

- Example Route

```js

// impoert express
const express = require('express');

// import Controller
const userController = require('../controllers/userController');

const router = express.Router();

// All routes goes here

module.exports = router;

```

## Notes

- The default property is only added if specified; otherwise, it’s omitted.
- Avoids redundant model, controller and route creation by confirming overwrites for existing.
- Ensure `mongoose` is installed in your project to use the generated models.
- More fuctions will be add in Future Releases.

## Releases

### v1.0.0 30 October 2024

- inital release
- Adding only Model

### v2.0.0 04 November 2024

- Adding Controllers
- fixing bugs on model

### v3.0.0 07 November 2024

- Adding Routes
- fixing bugs on model and Controllers