项目作者: kaxi1993

项目描述 :
MERN boilerplate generator. Mongo, Express, React, Node web app.
高级语言: JavaScript
项目地址: git://github.com/kaxi1993/mern-template.git
创建时间: 2018-01-12T07:54:08Z
项目社区:https://github.com/kaxi1993/mern-template

开源协议:MIT License

下载


mern-template

npm version
codecov
Known Vulnerabilities
npm

mern-temlate is a cli tool for generating isomorphic and modular mongo, express, react and node web app. The project is based on the best practices and popular tools. This is not just a simple starter that generates only the folder structure, but a real example of a production ready web application.

Table of contents

Visualization

alt text

Installation

  1. npx mern-template my-app

or

  1. npm install mern-template -g
  2. mern-template my-app

Run Project

  1. cd my-app
  2. npm install
  3. npm start

or

  1. cd my-app
  2. docker-compose up

Project Structure

  1. |__ bin
  2. |__ client
  3. |__ config
  4. |__ public
  5. |__ server
  6. |.. docker-compose.yml
  7. |.. Dockerfile
  8. |.. Dockerfile-development
  9. |.. jest.config.js
  10. |.. package.json
  11. |.. process.json
  12. |.. project.config.js
  13. |.. webpack.common.js
  14. |.. webpack.dev.js
  15. |.. webpack.prod.js

bin

bin folder contains file named www from where we start express server and connect to mongodb.

config

I use dotenv to load environment variables. If NODE_ENV is development or test, environment variables are loaded from config/.development and config/.test files relatively. In production it is better to enter all your environment variables from console. It isn’t good idea to upload environment variables on github.

client

client folder contains react code. I use redux and redux-saga for state management,
react-router-dom to handle client side routing and material-ui as a UI framework. I use scss preprocessor with bem methodology.

public

public folder contains static assets.

server

server side code has following structure:

  1. |__ server
  2. |__ auth
  3. |__ tasks
  4. |__ users
  5. |.. app.js
  6. |.. db.js
  7. |.. routes.js

and each module looks like this:

  1. |__ tasks
  2. |__ __tests__
  3. |.. index.js
  4. |.. task-controller.js
  5. |.. task-model.js
  6. |.. task-validation.js

I use jest for testing, joi for validation, passport-jwt for authentication, mongoose driver for mongodb and signale for logging.

License

Copyright (c) 2019 Lasha Kakhidze. This code is released under the MIT license.