📕
Dan Fitz's Notes
  • README
  • Ai
    • Supervised Machine Learning
      • Introduction To Machine Learning
      • Regression With Multiple Input Variables
      • Classification
  • Csharp
    • C Sharp Advanced
      • Generics
      • Delegates
      • Lambda Expressions
      • Events
    • C Sharp Fundamentals
      • Intro To C
      • Primitive Types And Expressions
      • Non Primitive Types
      • Control Flow
      • Arrays And Lists
      • Working With Dates
      • Working With Text
      • Working With Files
      • Debugging Applications
    • C Sharp Intermediate
      • Classes
      • Association Between Classes
      • Inheritance
      • Polymorphism
      • Interfaces
  • Java
    • Inheritance Data Structures Java
      • Inheritance Polymorphism Using Overriding And Access Modifiers
      • Abstract Classes And Debugging
      • File I O And Exceptions
      • Collections Maps And Regular Expressions
    • Intro To Java
      • Introduction To Java Classes And Eclipse
      • Unit Testing Arrays And Array Lists
      • Static Variables Methods And Polymorphism Using Overloading
  • Javascript
    • Algorithms Data Structures
      • Big O Notation
      • Analyzing Performance Of Arrays And Objects
      • Problem Solving Approach
      • Problem Solving Patterns
      • Recursion
      • Searching Algorithms
      • Bubble Selection And Insertion Sort
      • Merge Sort
      • Quick Sort
      • Radix Sort
      • Data Structures Introduction
      • Singly Linked Lists
      • Doubly Linked Lists
      • Stacks And Queues
      • Binary Search Trees
      • Tree Traversal
      • Binary Heaps
    • Complete Nodejs
      • Understanding Node.js
      • REST AP Is And Mongoose
      • API Authentication And Security
      • Node.js Module System
      • File System And Command Line Args
      • Debugging Node.js
      • Asynchronous Node.js
      • Web Servers
      • Accessing API From Browser
      • Application Deployment
      • Mongo DB And Promises
    • Complete React Native
      • Working With Content
      • Building Lists
      • Navigating Users Between Screens
      • State Management
      • Handling Screen Layout
      • Setting Up An App
      • More On Navigation
      • Advanced Statement Management With Context
      • Building A Custom Express API
      • In App Authentication
    • Epic React
      • React Fundamentals
      • React Hooks
      • Advanced React Hooks
      • Advanced React Patterns
      • React Performance
    • Fireship Firestore
      • Firestore Queries And Data Modeling Course
      • Model Relational Data In Firestore No SQL
    • Functional Light Javascript
      • Intro
      • Function Purity
      • Argument Adapters
      • Point Free
      • Closure
      • Composition
      • Immutability
      • Recursion
      • List Operations
      • Transduction
      • Data Structure Operations
      • Async
    • Js Weird Parts
      • Execution Contexts And Lexical Environments
      • Types And Operators
      • Objects And Functions
      • Object Oriented Java Script And Prototypal Inheritance
      • Defining Objects
    • Mastering Chrome Dev Tools
      • Introduction
      • Editing
      • Debugging
      • Networking
      • Auditing
      • Node.js Profiling
      • Performance Monitoring
      • Image Performance
      • Memory
    • React Complete Guide
      • What Is React
      • React Basics
      • Rendering Lists And Conditionals
      • Styling React Components
      • Debugging React Apps
      • Component Deep Dive
      • Building A React App
      • Reaching Out To The Web
      • Routing
    • React Testing
      • Intro To Jest Enzyme And TDD
      • Basic Testing
      • Redux Testing
      • Redux Thunk Testing
    • Serverless Bootcamp
      • Introduction
      • Auction Service Setup
      • Auction Service CRUD Operations
      • Auction Service Processing Auctions
    • Testing Javascript
      • Fundamentals Of Testing
      • Static Analysis Testing
      • Mocking Fundamentals
      • Configuring Jest
      • Test React Components With Jest And React Testing Library
    • Typescript Developers Guide
      • Getting Started With Type Script
      • What Is A Type System
      • Type Annotations In Action
      • Annotations With Functions And Objects
      • Mastering Typed Arrays
      • Tuples In Type Script
      • The All Important Interface
      • Building Functionality With Classes
    • Web Performance With Webpack
      • Intro
      • Code Splitting
      • Module Methods Magic Comments
  • Other
    • Algo Expert
      • Defining Data Structures And Complexity Analysis
      • Memory
      • Big O Notation
      • Logarithm
      • Arrays
      • Linked Lists
      • Hash Tables
      • Stacks And Queues
      • Strings
      • Graphs
      • Trees
    • Aws Solutions Architect
      • AWS Fundamentals IAM EC 2
    • Fundamentals Math
      • Numbers And Negative Numbers
      • Factors And Multiples
      • Fractions
    • Mysql Bootcamp
      • Overview And Installation
      • Creating Databases And Tables
      • Inserting Data
      • CRUD Commands
      • The World Of String Functions
      • Refining Our Selections
      • The Magic Of Aggregate Functions
    • Random Notes
      • Understanding React Hooks
  • Python
    • Data Analysis Using Python
      • Loading Querying And Filtering Data Using The Csv Module
      • Loading Querying Joining And Filtering Data Using Pandas
      • Summarizing And Visualizing Data
    • Intro To Python
      • Course Introduction Intro To Programming And The Python Language Variables Conditionals Jupyter Notebook And IDLE
      • Intro To Lists Loops And Functions
      • More With Lists Strings Tuples Sets And Py Charm
      • Dictionaries And Files
Powered by GitBook
On this page
  • SSH Connection
  • GitHub
  • Heroku
  • Avoid Global Modules
  1. Javascript
  2. Complete Nodejs

Application Deployment

SSH Connection

Applications like GitHub and Heroku allow an SSH connection. To set this up, do the following:

  1. Run ssh-keygen -t rsa -b 4096 -C "dan@danfitz.com" to create an RSA public and private key pair.

    • -t rsa defines the algorithm.

    • -b 4096 is the most common byte size.

    • -C "dan@danfitz.com" is the comment, which is usually your email.

  2. Save the key pair to the default location: ~/.ssh. Also, set the passphrase to a default of none. This will generate an RSA public and private key pair: id_rsa and id_rsa.pub.

  3. Start up a new SSH agent: eval "$(ssh-agent -s)". This will create a new agent or give you the ID of the one already running.

  4. Add the private key to the SSH agent: ssh-add ~/.ssh/id_rsa.

  5. In your service of choice, add the contents of the public key in the id_rsa.pub file to your account. (Just use cat to print it out.)

GitHub

The value of SSH with GitHub is that you can connect without a username and password! To test that GitHub is authenticated, run ssh -T git@github.com. You should see a success message!

Heroku

Heroku allows configuration in the command line.

  1. Run heroku keys:add, and it will find id_rsa.pub automatically.

  2. Then run heroku create <appName> to create new app.

  3. Now Heroku needs an npm start command, which it will execute on the server. Simply add this inside scripts in package.json:

    • "start": "node path/to/app.js"

  4. Heroku provides your server with its own port environment variable, so you need to add it to your app.listen function call.

const port = process.env.PORT || 3000
// NOTE: You provide a fallback value for the local dev environment

app.listen(port, ...)

Note: Make sure any URLs for other parts of your site use a relative path (e.g. /about instead of localhost:3000/about).

  1. Finally, stage and commit your code and then git push heroku master. Heroku will deploy your application for you!

Avoid Global Modules

If you have a global module, this is bad for other people who want to work on your project. When they git clone your project and then npm install your dependency modules, global modules aren't included in your package.json. The solution is to add the module as a local module!

Bonus: Some of these local modules will be dev dependencies. These dependencies are separated, so the production server doesn't install unnecessary files. For example, nodemon is useful for a dev to hot reload your local website, but it's useless in a production environment. To implement a dev dependency, do the following:

  • Simply flag your install as npm install --save-dev nodemon.

  • Then make sure any scripts your deployment server runs don't include dev dependencies.

Note: If you want to run a command in the command line using a local module, you can use npx like npx nodemon src/app.js.

PreviousAccessing API From BrowserNextMongo DB And Promises

Last updated 3 years ago