Coder Social home page Coder Social logo

simpleblog's Introduction

simpleBlog

A basic blog application made with Node + express + Mongo + React made as an exercise for my Web Development Class.

Organization

The root folder contains a basic express application generated with express-generator. The public folder contains a basic frontend built with jade as a demonstration, but the final frontend was created with create-react-app and resides in the front folder. Notice that the front folder is a whole different project.

Developing

Start the server, you can test it on https://localhost:3001

yarn install
yarn start

Start the client, you can test it on https://localhost:3000. Use this URL for development, as react has been configured to connect to the backend on 3001 when doing AJAX.

cd front
yarn install
yarn start

Have an instance of mongo running, and set the mongo url to the MONGO_URL environment variable. If not variable is found then mongodb://localhost:27017 will be used.

Preparing for deployment

yarn install
cd front
yarn install
yarn run build
cd ..
yarn start

Deploying to Heroku

_. Follow carefully the steps here: https://devcenter.heroku.com/articles/deploying-nodejs _. Create a free account in mongo atlas, start a new cluster. _. Make sure that you create a new user in mongo atlas with permissions to edit the database. _. Make sure that you whitelist your ip for connecting to the database *. Here is my package.json

{
  "name": "myblog",
  "version": "0.0.0",
  "private": true,
  "main": "./bin/www",
  "scripts": {
    "start": "node ./node_modules/nodemon/bin/nodemon.js ./bin/www",
    "heroku-postbuild": "cd front && yarn install && yarn run build"
  },
  "dependencies": {
    "cookie-parser": "~1.4.4",
    "debug": "~2.6.9",
    "express": "~4.16.1",
    "mongodb": "^3.6.2",
    "morgan": "~1.9.1"
  },
  "devDependencies": {
    "eslint": "^7.11.0",
    "eslint-config-prettier": "^6.13.0",
    "nodemon": "^2.0.6",
    "prettier": "^2.1.2"
  },
  "author": "John Alexis Guerra Gómez",
  "license": "MIT",
  "engines": {
    "node": "12.13.x",
    "yarn": "1.13.x"
  }
}

Notice the heroku-postbuild script which builds react for you, courtesy of @Suhas Mohan _. Create an environment variable MONGO_URL in your heroku deployment _. Success *. Hug your instructor

simpleblog's People

Contributors

john-guerra 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.