Skip to content

Instantly share code, notes, and snippets.

@karanpal-dhillon
Created February 26, 2019 15:07
Show Gist options
  • Save karanpal-dhillon/cd92cce1c568f5df94298508bb7158d9 to your computer and use it in GitHub Desktop.
Save karanpal-dhillon/cd92cce1c568f5df94298508bb7158d9 to your computer and use it in GitHub Desktop.

Project Setup

There are two sample projects. aws-front-end and aws-back-end. aws-front-end is suppose to have internet facing VM (web server) and aws-back-end is suppose to be the app server, not accessible to the public.

Installation

Common software stack for both front end and backend

Node js is the only common SDK for both the projects.

  • Install node js (using nvm)
    • curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
    • source ~/.bashrc
    • nvm install node //This command will install latest LTS version of node and npm

Back end

  • Download the source code tar.gz file from Dropbox
  • Extract the source code file.
  • CD into the source code folder and modify database connection parameters.
    • config/db-config.js file contains DB connection parameters.
    module.exports = {
    database: 'edstart',
    username: 'postgres',
    password: 'postgres',
    host: 'edstart.cftv5465a2p0.us-east-1.rds.amazonaws.com',
    dialect: 'postgres'};
    • Modify above parameters according to current setup.
    • run npm install
    • run nohup node app.js & to start the server.
    • By default, port 3333 is assigned to the node process. There are two ways we can change the default port. Either we set an environment variable using export PORT=80 or we change the default port given in the app.js file. Change line const port = process.env.PORT || 3333; to the desired port.

Front end

  • Download the source code tar.gz file fron Dropbox
  • Extract the source code file.
  • CD into the source code folder and modify app server url
    • config/config.js file contains app server connection parameter.
     module.exports = {
     	baseUrl: 'http://172.31.23.197:3333'
     };
    • Modify above base url. (Internal IP of the app server)
    • run npm install
    • run nohup npm start & to start the server.
    • By default, port 3000 is assigned to the node process. Again, there are two ways to change the default port. Either we set an environment variable using export PORT=80 or we change the default port given in the bin/www file. Line no #41 const port = normalizePort(process.env.PORT || '3000');

Endpoints:

Business Form: http://ec2-3-88-157-200.compute-1.amazonaws.com:3000/businesses

Businesses List: http://ec2-3-88-157-200.compute-1.amazonaws.com:3000/businesses/list


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment