The rent monitor server API.
The default configuration uses a postgresql database. But any SQL database supported by loopback can be used.
In case you are using postgresql please run these commands to setup the databases:
createuser $RDS_USERNAME -P
CREATE USER $RDS_USERNAME WITH ENCRYPTED PASSWORD $RDS_PASSWORD;
createuser rentmonitor_test -P
createdb rentmonitor_test --owner rentmonitor_test --username <user with createdb permissions>
createdb $RDS_DB_NAME --owner $RDS_USERNAME --username <user with createdb permissions>
CREATE DATABASE $RDS_DB_NAME OWNER $RDS_USERNAME;
To setup both databases run:
npm run migrate npm run migrate:testdb
If you have trouble running the tests because the database schema is not up-to-date please run:
npm run migrate:testdb
docker network create rentmonitor-network docker run --network rentmonitor-network --name postgresdb -e POSTGRES_PASSWORD=postgres -d --restart unless-stopped arm32v6/postgres:13-alpine
docker exec -it postgresdb bash psql -h localhost -p 5432 -U postgres -W
CREATE ROLE $RDS_USERNAME WITH LOGIN PASSWORD $RDS_PASSWORD; CREATE DATABASE $RDS_DB_NAME OWNER $RDS_USER;
docker build -t arm32v6/rentmonitor-server-loopback:1.0.1 .
docker save -o /tmp/rentmonitor-server-loopback-1.0.1.img arm32v6/rentmonitor-server-loopback:1.0.1
scp /tmp/rentmonitor-server-loopback-1.0.1.img $RENTMONITOR_DEPLOY_HOST:~/rentmonitor-server-loopback-1.0.1.img
docker load -i rentmonitor-server-loopback-1.0.1.img
docker run --network rentmonitor-network --name rentmonitor-server -e RDS_HOSTNAME -e RDS_PORT -e RDS_DB_NAME -e RDS_USERNAME -e RDS_PASSWORD -e RENTMONITOR_DB_ENCRYPTION_SECRET -e RENTMONITOR_DB_ENCRYPTION_SALT -e RENTMONITOR_JWT_SECRET -p 3000:3000 -d arm32v6/rentmonitor-server-loopback:1.0.1
cat rentmonitor_dump.sql | docker exec -i postgresdb psql -U $RDS_USERNAME
psql -f rentmonitor-2021-07-14_15_00_01.sql --host $RDS_HOSTNAME --port $RDS_PORT --username $RDS_USERNAME --dbname $RDS_DB_NAME
eb create rentmonitor-server-loopback-dev --region us-east-1 --elb-type application --database.engine postgres --database.user $RDS_USERNAME --database.password $RDS_PASSWORD --envvars TZ='UTC' RENTMONITOR_DB_ENCRYPTION_SECRET=$RENTMONITOR_DB_ENCRYPTION_SECRET,RENTMONITOR_DB_ENCRYPTION_SALT=$RENTMONITOR_DB_ENCRYPTION_SALT,RENTMONITOR_JWT_SECRET=$RENTMONITOR_JWT_SECRET
TZ='UTC' PORT=3001 DEBUG=loopback:connector* node --inspect .
cmd + shift + p -> attach to process
npx serverless deploy
npx serverless info
npx serverless remove