api-node-agriedge v1.0.0
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
NVM (NOT NPM):
brew install nvm
Writing alias, IF Bash, type:
echo "source $(brew --prefix nvm)/nvm.sh" >> .bash_profile
Writing alias, IF zsh/oh-my-zsh, type:
echo "source $(brew --prefix nvm)/nvm.sh" >> .zhsrc
Reload profile, IF bash, type:
~/.bash_profile
. IF zsh, type:. ~/.zshrc
NODE:
nvm use
NPM PACKAGES:
npm install
GLOBAL SERVERLESS:
npm -g install serverless
DOCKER: web Note: Using homebrew will not work, need to install the docker desktop application.
DOCKER MYSQL:
docker pull mysql
Development
npm start
IN A PARALLEL TERMINAL WINDOW
npm run hydrate
(this will hydrate your local database)Happy Coding :)
Write tests
Create a PR
Deployment
Below are the steps required to deploy this app to an AWS environment.
Install AWS CLI
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
In your AWS Account add an s3 bucket to hold deployments (currently set in
serverless.yml:61
)npm run deploy
(currently set todev
, use env variable or manually change for other environments)
3 years ago