1.0.0 • Published 3 years ago

api-node-agriedge v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

AGRIEDGE backend

Agriedge is built on the serverless framework which utilizes Cloudformation to keep track of our stack and be able to quickly re-build if needed or replicate in other environments. The backend API is on a single lambda function (not a microservice) with an RDS instance behind it for a MySQL database. Connection information to this RDS instance is set in the env folders in ./aws/envs

Local Development

Below are the steps required to run this app local.

Installation

  1. NVM (NOT NPM): brew install nvm

  2. Writing alias, IF Bash, type: echo "source $(brew --prefix nvm)/nvm.sh" >> .bash_profile

  3. Writing alias, IF zsh/oh-my-zsh, type: echo "source $(brew --prefix nvm)/nvm.sh" >> .zhsrc

  4. Reload profile, IF bash, type: ~/.bash_profile. IF zsh, type: . ~/.zshrc

  5. NODE: nvm use

  6. NPM PACKAGES: npm install

  7. GLOBAL SERVERLESS: npm -g install serverless

  8. DOCKER: web Note: Using homebrew will not work, need to install the docker desktop application.

  9. DOCKER MYSQL: docker pull mysql

Development

  1. npm start

  2. IN A PARALLEL TERMINAL WINDOW npm run hydrate (this will hydrate your local database)

  3. Happy Coding :)

  4. Write tests

  5. Create a PR

Deployment

Below are the steps required to deploy this app to an AWS environment.

  1. Install AWS CLI

  2. run aws configure

DO YOU HAVE MULTIPLE AWS ACCOUNTS, THEN DO THE FOLLOWING (OPTIONAL):

2a. Add Load config variable to your terminal export AWS_SDK_LOAD_CONFIG=1 >> ~/.zshrc (or ~/.bashrc if using bash; use echo $SHELL to determine)

2b. Please add an aws config file to ~/.aws/config; below is a TEMPLATE example, please edit accordingly:

[profile default]
region=us-east-2
output=json

[profile local] # this can be fake, we only need it for local development
role_arn=arn:aws:iam::111222333444:role/Developer
source_profile=default

[profile ENTER-ENV-NAME]
role_arn=arn:aws:iam::ADD-ENV-ACT-NUMBER:role/ADD-ENV-ROLE-NAME
source_profile=default

2c. Uncomment line serverless.yml:57

  1. In your AWS Account add an s3 bucket to hold deployments (currently set in serverless.yml:61)

  2. npm run deploy (currently set to dev, use env variable or manually change for other environments)