npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

automate-backend-fullstack

v3.0.0

Published

Automate MVC of the Backend FullStack Projects

Downloads

207

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:

    npm install -g automate-backend-fullstack 

Usage

  • To create a new model, simply run:

    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:

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

// 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


// 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