Giter Site home page Giter Site logo

amazingandyyy / mern Goto Github PK

View Code? Open in Web Editor NEW
497.0 18.0 282.0 35.26 MB

๐ŸŒ MERN stack 2.0 - MongoDB, Express, React/Redux, Node

Home Page: https://amazingandyyy.com/mern

License: MIT License

JavaScript 93.01% HTML 3.62% SCSS 3.37%
react redux mongodb jwt starter-kit express mern-boilerplate mern-stack nodejs expressjs boilerplate boilerplate-template mern fullstack

mern's Introduction

๐ŸŒ MERN Stack

MongoDB, Expressjs, React/Redux, Nodejs

MERN is a fullstack implementation in MongoDB, Expressjs, React/Redux, Nodejs.

MERN stack is the idea of using Javascript/Node for fullstack web development.

clone or download

$ git clone https://github.com/amazingandyyy/mern.git
$ yarn # or npm i

project structure

LICENSE
package.json
server/
   package.json
   .env (to create .env, check [prepare your secret session])
client/
   package.json
...

Usage (run fullstack app on your machine)

Prerequisites

notice, you need client and server runs concurrently in different terminal session, in order to make them talk to each other

Client-side usage(PORT: 3000)

$ cd client          // go to client folder
$ yarn # or npm i    // npm install packages
$ npm run dev        // run it locally

// deployment for client app
$ npm run build // this will compile the react code using webpack and generate a folder called docs in the root level
$ npm run start // this will run the files in docs, this behavior is exactly the same how gh-pages will run your static site

Server-side usage(PORT: 8000)

Prepare your secret

run the script at the first level:

(You need to add a JWT_SECRET in .env to connect to MongoDB)

// in the root level
$ cd server
$ echo "JWT_SECRET=YOUR_JWT_SECRET" >> src/.env

Start

$ cd server   // go to server folder
$ npm i       // npm install packages
$ npm run dev // run it locally
$ npm run build // this will build the server code to es5 js codes and generate a dist file

Deploy Server to Heroku

$ npm i -g heroku
$ heroku login
...
$ heroku create
$ npm run heroku:add <your-super-amazing-heroku-app>
// remember to run this command in the root level, not the server level, so if you follow the documentation along, you may need to do `cd ..`
$ pwd
/Users/<your-name>/mern
$ npm run deploy:heroku

After creating heroku

if using webpack: remember to update the file of client/webpack.prod.js

 'API_URI': JSON.stringify('https://your-super-amazing-heroku-app.herokuapp.com')

if using parcel remember to update the file of client/.env.production

 REACT_APP_API_URI=https://your-super-amazing-heroku-app.herokuapp.com

Dependencies(tech-stacks)

Client-side Server-side
axios: ^0.15.3 bcrypt-nodejs: ^0.0.3
babel-preset-stage-1: ^6.1.18 body-parser: ^1.15.2
lodash: ^3.10.1 cors: ^2.8.1
react: ^16.2.0 dotenv: ^2.0.0
react-dom: ^16.2.0 express: ^4.14.0
react-redux: ^4.0.0 jwt-simple: ^0.5.1
react-router-dom: ^4.2.2 mongoose: ^4.7.4
redux: ^3.7.2 morgan: ^1.7.0
redux-thunk: ^2.1.0

Screenshots of this project

User visit public and Home page User visit public and Home page

User can sign in or sign up User can sign in or sign up

After signing in user can go to account route and make request to token-protected API endpoint After signing in user can go to account route

Standard

JavaScript Style Guide

BUGs or comments

Create new Issues (preferred)

Email Me: [email protected] (welcome, say hi)

Author

Amazingandyyy

I recently launch my monthly mentorship program, feel free to reach out and see what we can grow together:

MentorCruise

Join the growing community

Star History Chart

License

MIT

mern's People

Contributors

amazingandyyy avatar amazingshellyyy avatar amjasser avatar equimper avatar farhan787 avatar jsoref avatar sundaram2021 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mern's Issues

Lack of babel version causes version conflict

Describe the error/difficulties:

The client runs wrong becuse there's no babel or its related dependent packages in your package.json, like @babel/core, babel-loader. It causes errors and interrupted the running process.

What have you done:

I've tried to yarn add these required babel package, but it seems the latest version is not compatible with your project. Then I tried yarn remove these packages, rm -rf package-lock.json node-modules and install a lower version of babel-loader, the problem is still there.

What it supports to do?

Please specify your babel version and add them to your package.json.

help_needed: Andy! help me: HEROKU

Describe the error/difficulties:

What have you done:

  • added .env in server/src/.env,
  • added JWT_SECRET and VALUE "mongodb+srv://:@uniquealterations-khlsn.mongodb.net/test?retryWrites=true&w=majority"

MONGODB_URI=mongodb+srv://:@.mongodb.net/test?retryWrites=true&w=majority

What it supports to do?

  • connect to mongoDb remote servers

Client "npm i" failing

Describe the error/difficulties:

  • Trying to do "npm i" on client throws dependency issues with redux and redux-thunk. After bypassing that there's "node-sass" and "node-gyp" build errors at the end of the "npm i" causing it to fail.

What have you done:

  • Re-installed Python, node and Visual Studio
  • Tried --force, --legacy-peer-deps and downgrading/upgrading respective packages
  • Deleted node modules and retried "npm i"
  • Reconfigured Path env to include Python and VS paths
  • Added python.exe to npm config
  • npm i -g node-sass
  • npm cache clean --force
  • npm install --global windows-build-tools
  • Tried almost everything in this

I am new to MERN but understand enough to be able to customize this code if I can get it to run. But the client side "npm install" process isn't executing without errors. Is this a local error on my behalf or a problem with node-sass? I have my environment paths and installs already configured. Any help would be appreciated if possible. Thank you.

Help Needed:MERN Stack (React )

Describe the error/difficulties:

  • TypeError: _article_content__WEBPACK_IMPORTED_MODULE_1___default.a.find is not a function

What have you done:

-I have created pages using React. Now when I load the page its showing TypeError

error1

**import React from "react";
import articleContent from './article-content';

const Article = ({match}) => {
const name=match.params.name;
const article=articleContent.find((article) => article.name === name);
return (


{article.title}


{article.content.map((paragraph,index)=>(

{paragraph}


))}

    </div>
)
        }**

export default Article

This is the code.

Error: No JWT_SECRET in env variable

Hi, I get this error, but there are no instructions on how to fix it..

I have created an .env file and it's accessible, what do I put in it?

Thanks in advance!

help_needed: Andy! help me:

Hi Andy,
thanks for the boilerplate, which is really helpful.
I have a question regarding the boilerplate. Is there any reason behind the fact that api/authentication.js and user/controller.js contain identical code?

Wouldn't it be reasonable two have everything in one place?

Example `.env` file

What am I supposed to add to the .env file?
A .env.example file would really help.

Update to React 17

Describe the error/difficulties:

  • React 16 seems to be outdated soon

What it supports to do?

  • Update to React 17

Nodemon not installed error

Once I installed npm i and ran run dev, I was presented with the nodemon error in cmd so I went ahead and installed the package, just thought I should I should bring up the issue.

Please help with client issue and npm install on main folder

First of all thanks for the boilerplate. Im facing 2 issues one with npm install on main folder. Im getting the following error:

@amazingandyyy/[email protected] install /Users/noman/mern/mern/node_modules/@amazingandyyy/git-hooks
node install

internal/fs/utils.js:759
throw new ERR_INVALID_ARG_TYPE('mode', 'integer', mode);
^

TypeError [ERR_INVALID_ARG_TYPE]: The "mode" argument must be integer. Received type string ('utf-8')
at Object.copyFileSync (fs.js:1989:10)
at installHook (/Users/noman/mern/mern/node_modules/@amazingandyyy/git-hooks/install.js:29:10)
at Array.forEach ()
at Object. (/Users/noman/mern/mern/node_modules/@amazingandyyy/git-hooks/install.js:35:7)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'ERR_INVALID_ARG_TYPE'
}
npm WARN [email protected] requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @amazingandyyy/[email protected] install: node install
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @amazingandyyy/[email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/noman/.npm/_logs/2021-02-05T04_55_14_942Z-debug.log

and another Im facing is that whenever I try to run npm run dev on client folder the browser keeps loading and just won't show anything

node version: v14.15.4
npm version: 6.14.10

Failed Heroku Upload

Followed steps to the letter: Generated H10 error. Not sure why.

2019-03-19T05:24:29.206246+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nano-dashboard.herokuapp.com request_id=81a50644-b220-4bb2-8bbf-be8a3d65373f fwd="100.11.185.122" dyno= connect= service= status=503 bytes= protocol=https
2019-03-19T05:24:29.437559+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nano-dashboard.herokuapp.com request_id=b290beef-2849-4fe9-859f-ab53abb62da9 fwd="100.11.185.122" dyno= connect= service= status=503 bytes= protocol=https
2019-03-19T05:24:29.526472+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nano-dashboard.herokuapp.com request_id=f33d4639-2891-4929-84a4-6d6bc05c03a3 fwd="100.11.185.122" dyno= connect= service= status=503 bytes= protocol=https
2019-03-19T05:24:29.366195+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nano-dashboard.herokuapp.com request_id=85ffe35e-c9ee-4122-92f6-0b511429213e fwd="100.11.185.122" dyno= connect= service= status=503 bytes= protocol=https
2019-03-19T05:24:55.422782+00:00 heroku[run.1538]: State changed from starting to up
2019-03-19T05:24:55.533692+00:00 heroku[run.1538]: Awaiting client
2019-03-19T05:24:55.636023+00:00 heroku[run.1538]: Starting process with command npm run dev
2019-03-19T05:24:52.651137+00:00 app[api]: Starting process with command npm run dev by user [email protected]
2019-03-19T05:25:00.763674+00:00 heroku[run.1538]: State changed from up to complete
2019-03-19T05:25:00.748041+00:00 heroku[run.1538]: Process exited with status 1
2019-03-19T05:29:38.649051+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nano-dashboard.herokuapp.com request_id=0c23bfa2-1ff4-41b3-b1e6-90072fdc0622 fwd="100.11.185.122" dyno= connect= service= status=503 bytes= protocol=https
2019-03-19T05:29:38.523443+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nano-dashboard.herokuapp.com request_id=ddec4dc0-c2e8-4f3b-a227-d06e861b0b2c fwd="100.11.185.122" dyno= connect= service= status=503 bytes= protocol=https
2019-03-19T05:29:57.715167+00:00 heroku[web.1]: State changed from crashed to starting
2019-03-19T05:29:59.499988+00:00 heroku[web.1]: Starting process with command npm start
2019-03-19T05:30:01.550951+00:00 heroku[web.1]: State changed from starting to crashed
2019-03-19T05:30:01.534006+00:00 heroku[web.1]: Process exited with status 1
2019-03-19T05:30:01.460918+00:00 app[web.1]: npm ERR! missing script: start
2019-03-19T05:30:01.470009+00:00 app[web.1]:
2019-03-19T05:30:01.470348+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-03-19T05:30:01.470487+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-03-19T05_30_01_462Z-debug.log
2019-03-19T05:35:50.963059+00:00 heroku[web.1]: State changed from crashed to starting
2019-03-19T05:35:53.040749+00:00 heroku[web.1]: Starting process with command npm start
2019-03-19T05:35:55.060313+00:00 heroku[web.1]: State changed from starting to crashed
2019-03-19T05:35:54.988110+00:00 app[web.1]: npm ERR! missing script: start
2019-03-19T05:35:54.995439+00:00 app[web.1]:
2019-03-19T05:35:54.995725+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-03-19T05:35:54.995818+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-03-19T05_35_54_989Z-debug.log
2019-03-19T05:35:55.041635+00:00 heroku[web.1]: Process exited with status 1

Remove .DS_STORE

Really nice stack buddy. But I think should be a good idea to gitignore all DS_STORE file ;)

help_needed: Andy! help me: connecting Heroku to ghpages

Describe the error/difficulties:

  • ghpages keeps saying oops server error but we don't see any issues with heroku

What have you done:

  • looked at the heroku logs and saw that we needed to add jwt secret but even after that gh pages fails to work

here's our github
https://github.com/codethechange/codethechange.konexio-mern-stack

here's the ghpage
https://codethechange.github.io/codethechange.konexio-mern-stack/

here's the heroku server
https://konexio-server.herokuapp.com/

NPM_CONFIG_PRODUCTION problem

Hi thanks for the repo.
when I run "npm i" I get this error:
'NPM_CONFIG_PRODUCTION' is not recognized as an internal or external command,

Adding Backend type

Describe the error/difficulties:

Updated New Userbase

What have you done:

What it supports to do?

Oops! Server Error, try later.

Great project, I clone repo and followed client instructions.
$ cd client
$ npm i
$ npm run dev

Project runs but always throws
Oops! Server Error, try later.

When I try signup up ?

Any ideas why ... see screenshot ....
screen shot 2018-02-26 at 10 31 05

Wrap it inside react fragment

          Thank you but it seems another problem. I ran the client and server locally and successfully but the http://localhost:3000 page is empty. There's an error on this page. 

image

image

I checked the dependence and React is installed.

Originally posted by @kaili-yang in #32 (comment)

Use github action!

Describe the error/difficulties:

  • github action is easier for everyone who fork this repo to enjoy the benefits of ci

What it supports to do?

  • github action to do linting, deploying to heroku, etc

Question

Great repo!

If I replace the mongodb url on lie 14 in server js with a mongolab url, will this repo work or do I need to do more to see it in action. Thanks again ! Mo

Error with command: npm i

Describe the error/difficulties:

npm ERR! code E401
npm ERR! Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Admin\AppData\Local\npm-cache_logs\2022-02-01T07_21_06_615Z-debug.log

What have you done:

npm i

What it supports to do?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.