Code Monkey home page Code Monkey logo

travelcamp-express-mongo's Introduction

TravelCamp

Welcome to TravelCamp!
A Travel Blog where everyone can create their own travel posts and view other users' experiences, as well as give reviews or contact with the posts' owners. As long as you sign up and log in, the whole blog is yours! Built in cloud9 - a powerful online code editor with a full Ubuntu workspace in the cloud.

Demo Version

travelCamp

Setup MongoDB

  1. If built with cloud 9, click here
  2. If built locally on Windows 10, installing mongodDB (currently mine is version 3.6) *** In case cannot run command mongod on Git Bash due to command not found and/or you haven't set up MongoDB environment, check Youtube tutorial or official MongoDB documentation

Install and running app

npm install 
  • express (Server-side Javascript)
  • ejs (Embedded Javascript)
  • body-parser (middleware: convert form data requests from user under req.body property as an object)
  • mongoose (mongoDB for Express version)
  • method-override (used for method PUT and DELETE in RESTful ROUTE that form type in cliend-side doesn't support
  • connect-flash (middleware: store message displayed for user once and cleared after page being refreshed)
  • passport
  • passport-local
  • passport-local-mongoose
  • express-session
node app.js 
  • It will direct to localhost:3000

Some definition during project:

  1. The differences between Authentication and Authorization:
  • Authentication: get people signup/login. In other words, people need to tell app/website who they are.
  • Authorization: Once figure out who user is, grant permission on specific things they are allowed to do.
  1. How To Do?
  • Hint:
    • Verify the id of current user with id of author who creates the post
    • However, id of current user - a string (req.user._id) is different than id of author (foundBlog.author.id) - a mongoose object
    • Instead of using: if(req.user._id === foundBlog.author.id). We use:
    if(foundBlog.author.id.equals(req.user._id)){
                   ...
           }
    

Heroku Deployment:

After project is done:

  1. In package.json:
"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1",
  "start": "node app.js"
}
  1. Setup your mlab before publishing project to heroku:
  • Name new database
  • Create new user
  • Replace code line in app.js: mongoose.connect("mongodb://<dbuser>:<dbpassword>@ds245228.mlab.com:45228/travelcamp")
  1. git cmd
  • git init
  • git add .
  • git commit -m "heroku deploy"
  • heroku create [app-name] (login and create new app, download Heroku CLI)
  • git push heroku master => done!
  • Or when you delete your current heroku app and want to deploy again:
  • git remote set-url heroku <new heroku git url>
  • git push heroku master => done!

Inspired by Web Developer Bootcamp - Colt Steele

travelcamp-express-mongo's People

Contributors

ninadang97 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.