Git Product home page Git Product logo

node-weather-website's Introduction

Heroku Installation

Setup Version Control with Git -> https://git-scm.com

  • Check git version -> git --version
  • Initialization of Git -> git init
  • To view .git on the VSCode, goto Code tab -> Preferences -> Settings -> Files: Exclude tab
  • Check current status of the repository files like Untracked files -> git status
  • Create a .gitignore file and add files which needs to be excluded
  • Add files to stage -> git add ... (OR) ...
  • To add all files to stage -> git add .
  • Unstage the staged files -> git rm --cached ...
  • Commit all files -> git commit -m "..."

Set up SSH(Secure Shell) for GitHub -> ls -a -l ~/.ssh (shows all ssh files if any (id_rsa, id_rsa.pub))

  • Generate ssh key -> ssh-keygen -t rsa -b 4096 -C "[email protected]" where t -> type b -> bytes (commonly 4096 bytes) C -> comments (like mail address)

  • Start the SSH agent -> eval "$(ssh-agent -s)" Output: Agent pid

  • Register SSH ssh-add -K ~/.ssh/id_rsa (OR) ssh-add -K /var/root/.ssh/id_rsa where K -> use this option only for Mac

  • Create a repository in GitHub

  • Push to existing repository using command git remote add origin https://github.com/myaqoob71/node-weather-website.git ->Creates a remote connection

  • Before running the below 2 commands we need to create a connection with SSH through GitHub

  • Goto GitHub profile -> Settings -> SSH and GPG keys -> Add New SSH key -> In VSCode terminal -> cat /var/root/.ssh/id_rsa.pub (OR) cat ~/.ssh/id_rsa.pub -> We get a long encrypted key -> Copy and paste it in GitHub -Tests your GitHub connection with servers -> ssh -T [email protected] -> git branch -M main -> git push -u origin main -> pushing code to upstream "main"

  • Setup SSH for Heroku -> heroku keys:add (Looks through the ssh directory and asks which ssh keys to upload)

  • Create a heroku application -> heroku create (This command gives 2 details)

  1. Tells about the successful creation of heroku application
  2. Provides 2 URL's -> (i): Live URL for the app (ii): git repository URL
  • For live app URL to run there are 3 changes to do:
  1. We need to create a script in package.json to start running the app.js "scripts": { "start": "node src/app.js" }
  2. In app.js, we need to make changes to listen() as heroku uses its own port to run application const port = process.env.PORT || 3000 -> heroku uses process.env.PORT and if we are running the app locally it uses 3000 port app.listen(port, () => { console.log('Server is up on port ' + port) })
  3. Also remove the dependency on localhost for fetch call in app.js fetch('http://localhost:3000/weather?address=' + location) -> Change to -> fetch('/weather?address=' + location)
  • Check remote -> git remote Output: heroku origin

  • Deploy code to heroku -> git push heroku main (Used for heroku to see latest commits has been pushed)

  • To update code and deploy to GitHub and Heroku

  1. git add ...
  2. git commit -m "..."
  3. git push
  4. git push heroku main
  • We removed the "nodemon" global dependency because when users try running the script it might fail as they didn't notice nodemon needs to be installed globally.
  • So, making it as a devDependency will be useful only for development purpose and not for production.
  • Now, we cannot directly run command -> nodemon src/app.js -e js,hbs (as its no more a globally installed package, but we can run it after adding as a script in package.json -> npm run dev)

NOTE: If using Windows machine use git bash command line prompt for all the terminal commands

node-weather-website's People

Stargazers

Roman avatar

Watchers

James Cloos avatar MOHAMMED YAQOOB 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.