Code Monkey home page Code Monkey logo

vue-express-app's Introduction

Vue Express Mongo App

Simple ecommerce app with Vue.js frontend, Express.js backend, Firebase authentication and MongoDB database.

See frontend/README.md and backend/README.md for more details.

Features

  • Products List
  • Product Details
  • Email Authentication (Firebase)
  • Managing Cart Items (Add, Remove) by authenticated users

Local Deployment

Prerequisites

  • Node.js
  • MongoDB Atlas
  • Firebase account and project

Steps

  • Clone the repository
git clone https://github.com/FlashDrag/vue-app
  • Install dependencies
cd frontend
npm install
cd ../backend
npm install
  • Create .env file in backend and frontend directories. See .env.example files for reference.
  • Run the backend server
cd backend
npm run dev
  • Run the frontend server
cd frontend
npm run serve

Production Deployment (Render)

  • Create a new web service on Render
  • Connect the web service to your GitHub repository
    • Branch: deployment
    • Root Directory: backend
    • Runtime: Node.js
    • Build Command: npm run build. It uses the script defined in package.json in the backend directory, see below.
    • Start Command: node ./build/server.js
    • Environment Variables: MONGO_DB_URL
  • Copy the web service URL
  • Replace the redirect URL in frontend/src/pages/ProductDetailPage.vue -> signIn() with the web service URL
  • Create a frontend build
cd frontend
npm run build
  • Copy the dist directory to the backend directory
cp -r dist ../backend/dist
  • Add script for deployment build to package.json in the backend directory
"scripts": {
// ...
"build": "npm install && npx babel ./src --out-dir ./build"
},
  • Add the following lines to backend/server.js
app.use(express.static(path.resolve(__dirname, '../dist'), { maxAge: '1y', etag: false }))
// ...
app.get("*", (req, res) => {
  res.sendFile(path.join(__dirname, "../dist/index.html"));
})
- Add authorised domains to Firebase Authentication
    - Go to Firebase Console -> Authentication -> Settings -> Authorized domains
    - Add your web service URL

vue-express-app's People

Contributors

pavlo-myskov avatar

Watchers

 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.