Giter Site home page Giter Site logo

daniel-knights / mevn-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 2.0 3.03 MB

A MEVN boilerplate setup with example CRUD, auth/user, email, validation, lazyload and pagination functionality out of the box.

Home Page: https://mevn-js.herokuapp.com/

JavaScript 40.84% HTML 2.21% Vue 40.17% SCSS 16.79%
mevn mevn-boilerplate mevn-stack mevn-scaffold vue vuejs vuejs2 vuex vue-router vue-cli vue-components express nodejs node nodemon axios sass expressjs mongodb spa

mevn-boilerplate's Introduction

MEVN Boilerplate

A MEVN boilerplate setup with:

  • Example CRUD functionality
  • Auth/user functionality
  • Lazy-loaded photos
  • Email
  • Validation
  • Pagination

Includes Heroku deployment walkthrough.

Requires manually setting up a MongoDB database.

Demo

From boilerplate

npm i -g nodemon
nodemon

cd client

npm i
npm run serve

Create a .env file in your root directory and add:

MONGO_URI=<your-mongodb-connection-string>
JWT_SECRET=<hex_string_from_server.js_function>
EMAIL_ACCOUNT=<your-gmail-account>
EMAIL_PASSWORD=<your-google-app-password>
PORT=3000

Create a .env file in the client directory and add:

VUE_APP_NODE_ENV=development

In server/routes/api/auth.js and server/routes/api/posts.js, inside the collection functions, replace "vue_express" with your database name:

return connection.db('vue_express').collection('users');

For the photo page to work, go to Pixabay and register for an account. Then go to the docs page, copy your given API key and replace <API_KEY> in the Axios request of the photos page.

Else, you can set up your own backend solution for photos and the frontend should fit to suit.

Create a Fontawesome kit and replace the one already in the <head> of client/public/index.html.

Then it will be available at http://localhost:8080.

From scratch

Express

npm init

npm i express cors mongodb dotenv bcryptjs jsonwebtoken compression helmet nodemailer morgan

In package.json replace

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
},

with

"scripts": {
    "start": "node server/server.js",
    "serve": "npm run serve --prefix client",
},

Vue

npm i -g @vue/cli #If not already installed

vue create client

cd client

npm i axios vue-outside-events vue-meta vue-lazyload vue-scrollactive vue-toasted

Deploy to Heroku

Vue

cd client
npm run build

Heroku

Make an account if you haven't already.

Then from your terminal:

heroku login
heroku create <your-app-name>

Then go to https://dashboard.heroku.com/apps click on your app, click 'deploy', choose the GitHub deployment method and follow the instructions.

Also, go to your apps settings and set config vars matching your root .env variables. Set a config var for VUE_APP_NODE_ENV but add a value of production instead of development, then add another variable with a key of NODE_ENV and value of production.

Troubleshooting

If you've chosen automatic GitHub deployment on Heroku and something isn't working, try manually deploying instead, sometimes the automatic deployment can act a little strange.

In MongoDB Atlas go to network access and allow IP addresses from anywhere or add specific IP addresses if known.

Make sure you run npm run build in /client before deploying or your changes won't be served.

If you're having trouble with Sass, make sure to install Live Sass Compiler (if using VSCode, otherwise consult the docs) and configure your settings.json to include this:

"liveSassCompile.settings.formats": [
    {
        "format": "compressed",
        "extensionName": ".min.css",
        "savePath": "/client/public/css"
    }
],

Otherwise, it may be an error on my end so submit an issue if you think this is the case.

Credit

Credit to Brad Traversy for providing most of this code from his tutorials. To learn more about this repo check out his videos covering both MERN and MEVN.

mevn-boilerplate's People

Contributors

daniel-knights avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

erko2 joewelds

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.