/frontend

Meteor front end

Primary LanguageJavaScriptGNU Affero General Public License v3.0AGPL-3.0

Unee-T

Overview

Demo - How to see how it works:

Environment variables

They are securely managed in AWS's parameter store. The variables are retrieved via an environment setup script, which is utilised by deploy.sh.

For local development, use ./env-setup.bash assuming you have been access to the uneet-dev development environment.

Deployment

Happens automatically on master on the development AWS account 8126-4485-3088 with AWS_PROFILE uneet-dev. Travis CI deployments made via pull request will fail since it will not have access to AWS_SECRET_ACCESS_KEY.

Production deployment on AWS account 1924-5899-3663 is done manually via ./deploy.sh -p via the AWS_PROFILE aws-prod only once the build is tagged.

Debugging with VScode

Background reading

  • cd .vscode; curl -O https://media.dev.unee-t.com/2018-07-05/launch.json for example, edit this to point to where your browser binary lives
  • npm run debug... you need to run this manually on the CLI
  • Meteor: Node to attach & debug server side
  • Meteor: Chrome to debug client side

Logs

Frontend logs to the meteor log group in CloudWatch, which is controlled by the compose file.

Meteor builds

The canonical master branch CI build location is https://unee-t-media.s3-accelerate.amazonaws.com/frontend/master.tar.gz

To discover other branches:

aws --profile uneet-dev s3 ls s3://unee-t-media/frontend/

Every commit is also uploaded to:

aws --profile uneet-dev s3 ls s3://unee-t-media/frontend/commit

Commits are expired after 90 days

Setup

  1. Install Meteor https://www.meteor.com/install

  2. Install dependencies

npm install

Start App

npm start

Tips

How do I figure out the email of the logged in user?

Run in browser's developer console:

Meteor.user().emails[0].address

How to find user account on MongoDB given an email address foo@example.com?

./backup/connect.sh
db.users.findOne({'emails.address': 'foo@example.com'})

How do I set up for local development?

  1. Make a backup snapshot of the development Mongo database using backup/dump.sh
  2. meteor reset to clear state
  3. npm run start to start the mongo service
  4. mongorestore -h 127.0.0.1 --port 3001 -d meteor $(date "+dev-%Y%m%d")/meteor

How to create users in the case my MongoDB is lacking the users?

To check the current users, connect to your MongoDB and run:

db.users.find({}, {'emails.address': 1, _id: 0}).map(d => d.emails[0].address).join('\n')

If your Frontend datastore MongoDB out of sync with your Bugzilla database's profiles, you need to create the users in the users manually:

Accounts.createUser({ email: 'leonel@mailinator.com', password: 'leonel', profile: { bzLogin: 'leonel@mailinator.com', bzPass: 'leonel' }})

Ensure it worked by looking at the npm start log. Next you might want to verify each user's email address.

db.users.update({'emails.address': 'leonel@mailinator.com'}, {$set : {'emails.0.verified': true}})

How to test the notifications / email templates?

Refer to simulate.sh though you need to tweak the events to map to the bugzillaCreds id from db.users.find().pretty()

Migrations: Not migrating, control is locked.

Migrations.unlock()
Migrations.migrateTo('latest')

error: Error: url must be absolute and start with http:// or https://

Your .env file is not set up correctly, consider ./env-setup.bash

Mail sending

The secret MAIL_URL environment variable configures the SMTP, so that email notifications can be sent. For example in uneet-dev environment, it begins with smtps://AKIAIICB7IAWDIGLY6DA.. and you can search for the Access key ID AKIAIICB7IAWDIGLY6DA in AWS IAM to determine if it's active or not in https://us-west-2.console.aws.amazon.com/ses/home?region=us-west-2#.

To help with debugging, there is a setup mail script to exercise MAIL_URL.