@mahjongg/mern-mvc
A CLI that will build a MERN stack application using create-react-app
Last updated 2 years ago by mahjongg .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @mahjongg/mern-mvc -g
SYNC missed versions from official npm registry.

Instructions:

This package relies on Yarn, so be sure that you have it installed globally.

npm install yarn -g

Next, install this package,

npm install -g @mahjongg/mern-mvc

Navigate to the desired location for your new project and run:

mern-mvc create <project-name>

mern-mvc will create a new folder for you with the name specified. This name will also be used in your package.json, so it must follow some naming conventions as required by npm. Only lowercase letters, numbers, or the "-" symbol are allowed.

What's Included?

mern-mvc creates an application that uses the following on the backend:

"dependencies": {
    "express",
    "express-session",
    "mongoose",
    "passport",
    "passport-local",
    "passport-local-mongoose"
  },
  "devDependencies": {
    "concurrently",
    "jest",
    "nodemon"
  }

All packages are installed at their most recent versions. It includes fully set-up user authentication, with the option for more fields to be added with ease.

You can opt out of passport set-up by using the flag --no-passport (aliased as -x).

A react application will be created using create-react-app, in a folder called 'client'. The dev dependencies concurrently and nodemon are used to allow both the react server and api server to be run in parallel when using yarn start. The react-app utilizes react-router-dom for routing, and axios for AJAX calls.

The React app has some very basic authentication forms included, but you are free to implement authentication however you like.

Route builder:

mern-mvc now includes a command for building a simple route file!

mern-mvc route <name> --options

The <name> parameter is used to determine the folder name to put the new route file in. You will still need to include that file somewhere and attach it to a specific path. Options include: --no-passport (-p): This will leave passport out of the function argument on your new route file. --no-functionBased (-f): This will create your route file so that it exports the Router object directly, rather than exporting a function that returns the Router. --routes (-r): This allows you to include a list of paths you want in your route. For simplicity, they are all created as GET routes, although it is simple enough to change them to some other method. The value provided to the --routes option should be include in double quotes and separated by a comma and a space. For example: mern-mvc route users --routes "signIn, signUp, signOut"

Will produce this file: users/index.js

module.exports = function(passport) {
	const router = require('express').Router();

	router.get("/signIn",function(req,res){

	});

	router.get("/signUp",function(req,res){

	});

	router.get("/signOut",function(req,res){

	});

    return router;
};

TODO:

other options to add to create command...

  • -r | no-react (for when the user has a premade react app)
  • -s | simple-routes (routes files are created as simple exports, rather than functions)
  • -n | no-npm (skips npm install, for quicker creation on slow connections. Still writes to package.json)

Current Tags

  • 1.4.0                                ...           latest (2 years ago)

19 Versions

  • 1.4.0                                ...           2 years ago
  • 1.3.1                                ...           2 years ago
  • 1.2.0                                ...           2 years ago
  • 1.1.1                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.14                                ...           2 years ago
  • 1.0.13                                ...           2 years ago
  • 1.0.12                                ...           2 years ago
  • 1.0.11                                ...           2 years ago
  • 1.0.10                                ...           2 years ago
  • 1.0.9                                ...           2 years ago
  • 1.0.8                                ...           2 years ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |