Giter Site home page Giter Site logo

samaricha / mern-shop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from achingachris/mern-shop

0.0 0.0 0.0 9.42 MB

Ecommerce Using the MERN STACK

Home Page: https://airshopnext.herokuapp.com/

JavaScript 97.74% HTML 1.82% CSS 0.43% Procfile 0.02%

mern-shop's Introduction

MERNSHOP

banner

Server:

Directory: server/

Client

Directory: client/

Preparing For Deployment

Environment configurations:

JWT_SECRET = 'secret'
MONGO_URI = 'mongodb_uri'
NODE_ENV = 'development'
PAYPAL_CLIENT_ID = 'paypal_id'
PORT = 5000

Change the NODE_ENV = 'development' to NODE_ENV = 'production' to run in production mode.

Create a build directory in the client directory,

$ npm run build

Esure you have the code, in your app.js in the server directory:

if (process.env.NODE_ENV === 'production') {
  app.use(express.static(path.join(__dirname, '/client/build')))

  app.get('*', (req, res) =>
    res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'))
  )
} else {
  app.get('/', (req, res) => {
    res.send('API is running....')
  })
}

Run the server in production mode(simulator):

$ npm start

Deploying to Heroku

On the root, create a Procfile file:

Tells heroku how to run the project on the server.

Add the following to the file:

$ web: node server/app.js

Create a heroku-postbuild script in package.json:

$ "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"

Add environment variables to Heroku's Config Vars.

Bugs

  1. File Uploads

Working Updates

  1. Re-write on Typescript

mern-shop's People

Contributors

achingachris avatar imgbotapp avatar

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.