Today was the second class day of the project. I spent an hour before class reviewing the visual docs and the various components in the business doc.
Log
7:00pm -
Challenge/Motivation
The challenge is to quickly gain a 30k foot view of the entire project and plan the skeleton and first steps without getting bogged down in any details yet.
Actions Taken
I read the documents and started copying spec files and other resources into our group Trello to keep everything in one place as the source of truth.
Results Observed
I felt more comfortable with our scope and workflow after reviewing docs and planning with the team.
11:00pm - finish setting up all collaborative tools (trello, github, docs, standup calendar etc.)
Challenge/Motivation
I wanted to make sure I had a mental model for the heirarchy of the project and workflow.
Actions Taken
I put reference to all of the spec docs into Trello as our ticket system will be the place of truth for feature, implementation, and research work.
Results Observed
I am much more comfortable with the skeleton of the journey we are about to embark on.
I wanted to get a skeleton with all div/elements and sub-components represented and get it rendered on the browser.
Actions Taken
I made an outline of all html elements over the visual example we were given with relative nexting represented by different colors.
Results Observed
I initially had a bug preventing render caused by some confusion about naming convention for our different components. I sent a slack message and we arrived at PascalCase and so I added that to my commit. I should have separated this debugging concern out but I needed to fix it for anything else to work. I'll only stage the files needed for that one concern going forward to keep commits and PRs granular.
I worked on rendering more aspects of the Ratings and Reviews component as well as getting Mock Data from the API using Postman and including it in the client side of the app.
Log
11:00am - 2:30pm
Challenge/Motivation
I wanted to import the star-review component that Milo created and make sure I understand how parameters are passed in and handled.
Actions Taken
Put the star review component into the appropriate div and passed a hard coded value as a placeholder.
Results Observed
Since the component already had div classNames and data-testid, there were redundant nesting of divs and the test suite broke. I removed the encapsulating divs from the top-level component and will continue to do so as I add sub-components. It will also be helpful to create the remaining components with react fragments to reduce the nested div clutter going forward.
Log
5:00pm - 7:30pm
Challenge/Motivation
I wanted to put a mock version of the various API GET query returns in the client side so all of the devs can use that to mock up the rendering of their components. It is also important to not keep querying the APIs since there are rate limits and we have already hit them before during development.
Actions Taken
I added mock data for all of the API GET requests. The data is currently imported into ProductDetailPage.jsx in the same data type as it returns from API GET requests (array/object). This is a temporary measure just to get the client passing the data in without constantly hitting the external API. I also created several tests for mock data types.
Results Observed
The data is being passed into a console.log statement and the tests are are currently directly accesssing the data exports from the folders structure. I want to refactor the mock data using jest or another API mock suite to accomplish testing the handling of data via API calls without overtaxing the API limits.
Today was spent deciding on short-term solution to state management. The entire cohort had a QnA session and passed ideas around about different approaches.
The primary options are:
classful component at top level with state passed via props and API request on Component lifecycle methods
classful sub components handling their own state w/ API requests
redux (we opted not to pursue this)
React hooks (Some of our components are moving to this and we will refactor more in coming weeks)
Log
9:00pm - 10:30pm
Challenge/Motivation
Our main work was to get all PRs having to do with mock data and API requests merged so everyone can start passing state to their components.
Actions Taken
We decided on putting the mock data at the client level for now. If the route already exists in the server, then leave it, but we'll put an alternate server mock next week after MVP demo.
Results Observed
We are getting data into the components that are setup to handle it and have a unified source of truth for the current structure.
I spent time making more detailed Trello tickets and drilled down into implementation level tasks
Actions Taken
I copied the spec into the about section of the tickets and imagined the scope of each aspect of the tickets to decide if I needed to break the task down into more implementation tickets.
Results Observed
I feel I have a better grasp on the scope of my widget and how the tasks are going to be broken down.
Log
5:00pm - 7:30pm
Challenge/Motivation
Investigate S3 storage and how to retrieve urls to send to Atelier API
Actions Taken
read S3 documentation and created a bucket. REST API endpoints are at s3-website-us-east-1.amazonaws.com with a bucket name "hr-nylon-eric-fec-bucket"
Results Observed
I setup an account and successfully uploaded an image to the s3 bucket.
Added Modal component for Review form
S3 bucket multiple file upload
Log
5:00am - 7:30pm
Challenge/Motivation
Get S3 route working as well as temporary storage of uploaded files on the client.
Actions Taken
I got single files working but was searching for a good solution to multiple file upload. Found a clever solution using generated local URLs to keep reference and load photos into the preview window.
I got the files to upload to the state array in the component. The display still needs to be worked on and I'll have to create a component(s) to display and map the 1-5 photos for preview.
Log
9:00pm - 11:30pm
Challenge/Motivation
Finish basic Modal form for Review uploads.
Actions Taken
I borrowed the patterns from the stateful class-based modal in the Overview module. I had to copy some interesting click handlers and deal with how they will work nested in a new component.
Results Observed
The basic form is rendering and I understand how the visible/invisible state is handled at the tope ProductDetailPage level. It is important to pay close attention to "this" identity as props and event handlers are being passed from one class-based stateful component to another for this modal functionality.
set up security policy on AWS EC2
I started with everything open and then restricted to port 80 UDP/TCP traffic for incomming. I also openned ICMP traffic for pinging purposes as well as ssh port 22 for logging into server.
set up elastic IP so it will persist after reboot/termination. you have to associate it to the instance from the elastic IP tab
Linux/UNIX instance:
AMI name: amzn2-ami-hvm-2.0.20210617.0-x86_64-gp2
Logging in:
ssh from local:
set permissions to pem file:
chmod 400 hr-nylon-eric.pem
This is a special Node build for AWS instances. Don't use standard Yum/apt install.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
To make sure that your PM2 restarts when your server restarts
pm2 startup
you will be given a custom string similar to this but specific to your machine, copy that:
sudo env PATH=$PATH:/home/ec2-user/.nvm/versions/node/v16.4.0/bin /home/ec2-user/.nvm/versions/node/v16.4.0/lib/node_modules/pm2/bin/pm2 startup systemd -u ec2-user --hp /home/ec2-user
save config with everything running (no nginx at this point)
pm2 save
pm2 start nodemon server/server.js
That’s it! You can log out/in to SSH, even restart your server and it will continue to run on port 80.
To list all processes use
pm2 ls
nginx persistent:
systemctl start nginxsystemctl enable nginx
having trouble restarting nginx on reboot,
sudo systemctl enable nginx
is supposed to solve it. needed to start nginx/ make persistant and THEN redo the pm2 process above
Results Observed
I got the app deployed pretty quickly but had to troubleshoot making the node server and nginx reverse-proxy persist after reboot.
Found approaches and landed on html validation on inputs with validation functions called on upload.
Results Observed
The basic validation options were pretty simple and effective. The next step would be to do some conditional styling like red outlines and UI feedback when users enter disallowed text.
Log
9:00pm - 10:30pm
Challenge/Motivation
Solve issues with the form elements not re-rendering on state change. This was particularly noticeable with the radio button as the button was one change behind. I also noticed that console.log of the state in every case was behind the actual state.
Actions Taken
I researched several articles and found 2 important concepts:
React setState only creates a pending queue for state transitions.
You should remove the event.preventDefault() from the event handler to make state update immediately.
Every change in radio button/ text field updates state and re-renders the form view. You can also pass a callback as a second argument to setState(state, () => {}); and perform operations after the async change.
1:00am - 3:30am
Challenge/Motivation
Get initial google page speed.
Actions Taken
Pulled down latest main branch on AWS deployment and built/transpiled newest changes. Results:
The results on desktop were middling at 73/100. Big issues are size of payload/bundle.js file as well as full size images being loaded. The results on mobile are worse at 23/100 especially because of the larger image sizes. We are working on using lazy loading as well as image compression to deal with these issues. It would also be good to limit image upload sizes and have a resolution conversion at the server for images that get uploaded via our routes to s3 storage.