Mastering Full Stack React Web Development 1st Edition Tomasz Dyl All Chapters Instant Download
Mastering Full Stack React Web Development 1st Edition Tomasz Dyl All Chapters Instant Download
com
https://textbookfull.com/product/mastering-full-stack-react-
web-development-1st-edition-tomasz-dyl/
OR CLICK BUTTON
DOWNLOAD NOW
Pro MERN Stack: Full Stack Web App Development with Mongo,
Express, React, and Node Vasan Subramanian
https://textbookfull.com/product/pro-mern-stack-full-stack-web-app-
development-with-mongo-express-react-and-node-vasan-subramanian/
textboxfull.com
Pro MERN Stack: Full Stack Web App Development with Mongo,
Express, React, and Node 2nd Edition Vasan Subramanian
https://textbookfull.com/product/pro-mern-stack-full-stack-web-app-
development-with-mongo-express-react-and-node-2nd-edition-vasan-
subramanian/
textboxfull.com
Pro MERN Stack: Full Stack Web App Development with Mongo,
Express, React, and Node 1st Edition Vasan Subramanian
(Auth.)
https://textbookfull.com/product/pro-mern-stack-full-stack-web-app-
development-with-mongo-express-react-and-node-1st-edition-vasan-
subramanian-auth/
textboxfull.com
https://textbookfull.com/product/full-stack-react-projects-modern-web-
development-using-react-16-node-express-and-mongodb-2nd-edition-shama-
hoque/
textboxfull.com
React Architect Full Stack React App Development and
Serverless Deployment Frank Zickert
https://textbookfull.com/product/react-architect-full-stack-react-app-
development-and-serverless-deployment-frank-zickert/
textboxfull.com
https://textbookfull.com/product/modern-full-stack-development-using-
typescript-react-node-js-webpack-and-docker-zammetti/
textboxfull.com
https://textbookfull.com/product/ultimate-nuxt-js-for-full-stack-web-
applications-1st-edition-lau-tiam-kok/
textboxfull.com
Tomasz Dyl
Kamil Przeorski
BIRMINGHAM - MUMBAI
Mastering Full-Stack React Web Development
Copyright © 2017 Packt Publishing
Every effort has been made in the preparation of this book to ensure
the accuracy of the information presented. However, the information
contained in this book is sold without warranty, either express or
implied. Neither the authors, nor Packt Publishing, and its dealers
and distributors will be held liable for any damages caused or
alleged to be caused directly or indirectly by this book.
www.packtpub.com
Credits
Copy Editors
Authors
Safis Editing
Tomasz Dyl
Kamil Przeorski
Madhusudan Uchil
Technical Editor
Prajakta Mhatre
About the Authors
Tomasz Dyl has worked with React since 2014. He's the technical
lead developer for React Poland. The team focuses on cross-platform
full-stack development using React and Node (http://reactpoland.com). He
has worked on over 20 different React and Node projects for his
clients since 2014. React Poland also works on the React Community
platform (https://reactjs.co).
Kamil Przeorski has worked with React since 2014. Along with
Tomasz, he is the co-founder of React Poland--the leading company
for React developers. In the meantime, besides building the best
React team in Poland, he runs two different Facebook groups called
Node.js Poland (https://www.facebook.com/groups/nodejsPL/) and ReactJS,
React Native, GraphQL (https://web.facebook.com/groups/reactjs.co/)--both
groups have around 2000 members.
About the Reviewer
Samer Buna is a coder, mentor, and technical content author. He
has a master's degree in Information Security, and years of
progressive experience and success creating tailored solutions for
businesses in many industries.
Samer has authored a few books and online courses about React
and GraphQL. You can follow him on Twitter at
https://twitter.com/samerbuna, and you can read more of what he writes at
https://edgecoders.com/.
www.PacktPub.com
For support files and downloads related to your book, please visit ww
w.PacktPub.com.
Did you know that Packt offers eBook versions of every book
published, with PDF and ePub files available? You can upgrade to the
eBook version at www.PacktPub.com and as a print book customer, you
are entitled to a discount on the eBook copy. Get in touch with us
at [email protected] for more details.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you
full access to all Packt books and video courses, as well as industry-
leading tools to help you plan your personal development and
advance your career.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Customer Feedback
Thanks for purchasing this Packt book. At Packt, quality is at the
heart of our editorial process. To help us improve, please leave us an
honest review on this book's Amazon page at https://www.amazon.com/dp/
1786461765.
If you'd like to join our team of regular reviewers, you can e-mail us
at [email protected]. We award our regular reviewers with free
eBooks and videos in exchange for their valuable feedback. Help us
be relentless in improving our products!
Dedication
- Kamil Przeorski
Table of Contents
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Configuring Full-Stack with Node.js, Express.js, MongoDB, Mongoose, Falcor, and Red
ux
More about our technical stack
Environment preparation
NVM and Node installation
MongoDB installation
Robomongo GUI for MongoDB
Running MongoDB and viewing our collections in the Robomongo GUI
Importing the first example collection into the database
Importing the articles to MongoDB
Server setup with Node.js and Express.js
Working on our server (server.js)
Mongoose and Express.js
A summary of how to run the project
Redux basic concepts
The single immutable state tree
Immutability - actions and state tree are read-only
Pure and impure functions
The reducer function
First reducer and webpack config
The rest of the important dependencies installation and npm dev script
Working on src/app.js and src/layouts/PublishingApp.js
Wrapping up React-Redux application
Finishing our first static publishing app
Falcor's basic concepts
What is Falcor and why do we need it in our full-stack publishing app?
Tight coupling and latency versus one model everywhere
No more tight coupling on client and server side
Client-side Falcor
A summary of client-side Falcor + Redux
Moving Falcor's model to the backend
Configuring Falcor's router (Express.js)
Second route for returning our two articles from the backend
Final touch to make full-stack Falcor run
Adding MongoDB/Mongoose calls based on Falcor's routes
Double-check with the server/routes.js and package.json
Our first working full-stack app
Summary
2. Full-Stack Login and Registration for Our Publishing App
Structure of JWT token
New MongoDB users collection
Explanation
Importing the initPubUsers.js file into MongoDB
Working on the login's falcor-route
Creating a falcor-router's login (backend)
How the call routes work
Separating the DB configs - configMongoose.js
Explanation
Improving the routes.js file
Explanation
Checking to see if the app works before implementing JWT
Creating a Mongoose users' model
Explanation
Implementing JWT in the routesSession.js file
Explanation
Successful login on falcor-route
Explanation
Frontend side and Falcor
The CoreLayout component
The LoginView component
A root's container for our app
Remaining configuration for configureStore and rootReducer
Last tweaks in layouts/PublishingApp.js before running the app
Last changes in src/app.js before running the app
Screenshots of our running app
Home page
Login view
Working on the login form that will call the backend in order to authenticate
Working on LoginForm and DefaultInput components
Explanation
LoginForm and making it work with LoginView
Improving the src/views/LoginView.js
Making DashboardView's component
Finishing the login's mechanism
Handling successful logins in the LoginView's component
Explanation
A few important notes about DashboardView and security
Starting work on the new editor's registration
Adding register's falcor-route
Explanation
Frontend implementation (RegisterView and RegisterForm)
RegisterView
Summary
3. Server-Side Rendering
When the server side is worth implementing
Mocking the database response
The handleServerSideRender function
Double-check server/server.js
Frontend tweaks to make the server-side rendering work
Summary
4. Advanced Redux and Falcor on the Client Side
Focusing on the app's frontend
Backend wrap-up before frontend improvement
Improving handleServerSideRender
Changing routes in Falcor (frontend and backend)
Our website header and articles list need improvements
New ArticleCard component
Dashboard - adding an article button, logout, and header improvements
Important note before creating a frontend add article feature
The AddArticleView component
Modifying DashboardView
Starting work on our WYSIWYG
Stylesheet for the draft-js WYSIWYG
Coding a draft-js skeleton
Improving the views/articles/AddArticleView component
Adding more formatting features to our WYSIWYG
Pushing a new article into article reducer
MapHelpers for improving our reducers
The CoreLayout improvements
Why Maps over a JS object?
Improving PublishingApp and DashboardView
Tweaks to AddArticleView
The ability to edit an article (the EditArticleView component)
Let's add a dashboard link to an article's edition
Creating a new action and reducer
Edit mode in src/components/articles/WYSIWYGeditor.js
Improvements in EditArticleView
EditArticleView's render improvements
Deleting an article's feature implementation
Summary
5. Falcor Advanced Concepts
The problem that Falcor aims to solve
Virtual JSON - one model everywhere
Falcor versus Relay/GraphQL
Big-picture similarities
Technical differences - overview
Improving our application and making it more reliable
Securing the auth required routes
JSON Graph and JSON envelopes in Falcor
Improving our Falcor code on the frontend
Improving server.js and routes.js
Falcor's sentinel implementation
The $ref sentinel
Detailed example of the $ref sentinel
Improving our articles' numberOfLikes with $ref
Practical use of $ref in our project
Mongoose config improvements
The server/routes.js improvements
JSON Graph atoms
Improving the articles[{integers}] route
New route in server/routes.js: articles.add
Frontend changes in order to add articles
Important note about route returns
Full-stack - editing and deleting an article
Deleting an article
Frontend - edit and delete
Securing the CRUD routes
The $error sentinel basics
DRY error management on the client side
Tweaks - FalcorModel.js on the frontend
Backend implementation of the $error sentinel
Testing our $error-related code
Cleaning up $error after a successful test
Wrapping up the routes' security
What routes to secure
Summary
6. AWS S3 for Image Upload and Wrapping Up Key Application Features
AWS S3 - an introduction
Generating keys (access key ID and secret key)
IAM
Setting up S3 permissions for the user
Coding the image upload feature in the AddArticleView
Environment variables in Node.js
Improving our Mongoose article schema
Adding routes for S3's upload
Creating the ImgUploader component on the frontend
Wrapping up the ImgUploader component
AddArticleView improvements
Some remaining tweaks for PublishingApp, ArticleCard, and DashboardVie
w
Improving the ArticleCard component
Improving the DashboardView component
Editing an article's cover photo
Adding the ability to add/edit the title and subtitle of an article
AddArticleView improvements
Ability to edit an article title and subtitle
ArticleCard and PublishingApp improvements
Dashboard improvement (now we can strip the remaining HTML)
Summary
7. The MongoDB Deployment on mLab
mLab overview
Replica set connections and high availability
MongoDB failover
Free versus paid plan in mLab
The new mLab's account and node
Creating the database's user/password and other configurations
Config wrap up
Summary
8. Docker and the EC2 Container Service
Docker installation with Docker Toolbox
Docker Hub - an hello world example
Dockerfile example
Modifications to our codebase in order to create it
Working on the publishing app Docker image
Building the publishing app container
Running the publishing app container locally
Debugging a container
Pushing a Docker container to a remote repository
A summary of useful Docker commands
Introduction to Docker on AWS EC2
Manual approach - Docker on EC2
Basics - launching an EC2 instance
SSH access via PuTTy - Windows users only
Connecting to an EC2 instance via SSH
Basics of ECS - AWS EC2
Working with ECS
Step 1 - creating a task definition
Step 2 - configuring the service
Step 3 - configuring the cluster
Step 4 - reviewing
Launch status
Finding your load balancer address
AWS Route 53
Summary
9. Continuous Integration with Unit and Behavioral Tests
When to write unit and behavioral tests
React conventions
Karma for testing
How to write unit and behavioral tests
What is Mocha and why do you need it?
Testing CoreLayout step-by-step
Continuous integration with Travis
Summary
Preface
The innovations in the JavaScript programming language in recent
years have been vital. For example, since 2009 the rise of Node
granted developers the ability to use the same programming
language in the browser and on the backend. The environmental
changes haven't slowed down in 2017 as well. This book will teach
you about some new and hot concepts that speed up the full-stack
development process even more.
In 2016 and 2017, there has been an even greater demand for
making apps even faster with full-stack technologies such as Falcor
or GraphQL. This book isn't just a guide on how to expose the API
endpoints in Node and start consuming them with your client-side
application. You will learn how to use the newest technology from
Netflix, called Falcor. Beside that, you will learn how to set up a
project with the use of React and Redux.
In this book, you will find a huge tutorial for building a full-stack app
from scratch with the use of the Node.js, Express.js, MongoDB,
Mongoose, Falcor, and Redux libraries. You will also learn how to
deploy your application with the use of Docker and Amazon's AWS
services.
What this book covers
Chapter 1,Configuring Full-Stack with Node.js, Express.js, MongoDB,
Mongoose, Falcor, and Redux, takes you through the initial setup of
the application from scratch. It helps you understand how different
libraries from npm make a usable full-stack React starter kit.
[
{
articleId: '987654',
articleTitle: 'Lorem ipsum - article one',
articleContent: 'Here goes the content of the article'
},
{
articleId: '123456',
articleTitle: 'Lorem ipsum - article two',
articleContent: 'Sky is the limit, the content goes here.'
}
]
mkdir server
cd server
touch index.js
New terms and important words are shown in bold. Words that
you see on the screen, for example, in menus or dialog boxes,
appear in the text like this: "Create a connection with defaults by
clicking the Create link."
If there is a topic that you have expertise in and you are interested
in either writing or contributing to a book, see our author guide at w
ww.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a
number of things to help you to get the most from your purchase.
Exploring the Variety of Random
Documents with Different Content
one over. For example, an eight strand braid requires 17 carriers,
while a 10 strand requires 21, and so on. The width of the braid may
be further regulated by the contraction of the goods determined upon
and provided for in the take-up; also by the size and character of the
material used for covering.
On account of the diagonal formation of the covering threads when
braiding, it will be seen that variable contraction of the web will
produce variable widths. This is not so with a woven elastic fabric,
inasmuch as the weft lies straight across the web and therefore the
same width is maintained whether it is stretched or otherwise. In
braiding, the threads move both across and lengthwise of the fabric,
taking the place of both warp and filling, therefore increased
contraction, no matter whether it is produced from the use of heavier
rubber, or changed material or take-up, results in greater width,
inasmuch as the lengthwise position of the threads is brought into a
new position which is more of a crosswise formation.
This diagonal lay of the covering threads opens up possibilities for
very effective plaid effects, but this is the limit of color elaboration. A
fancy frill effect may be obtained by the omission of rubber threads
at the outer edges.
Chapter XI.
WEAVING THE VAN HEUSEN COLLAR
Heavy Loom Required—How Long-Sided Effect and Folding Line
Are Obtained—Cloth Construction
Until recently the soft collar was cut and carved into shape from
plain piece goods. The patented Van Heusen collar has done away
with much of this, for from the loom is produced a fabric properly
shaped and formed for the purpose, and ready to be cut into suitable
lengths. It is adapted to various styles. Clumsy joinings are done
away with and a collar is produced which combines shape, comfort
and appearance. Much labor in collar manufacturing is also
eliminated by this method of production.
There have recently been quite a number of factories put on the
production of these goods, and at least one newly organized factory
is devoted exclusively to their manufacture. The main feature in the
Van Heusen collar is that it is woven in such a manner that when it
leaves the loom it is complete in respect of the cloth for the band and
outer part, with provision made for folding, thus doing away with any
joining together of the two parts as formerly.
The formation of a cloth having the novel quality of allowing for a
greater woven length at the outer edge of the collar than at the band,
properly graded throughout so as to meet all the requirements of a
collar in comfort and fit, at the same time providing for the insertion
of the scarf so that it will run easily, and also allowing for the
production of a variety of styles, calls for features in manufacturing
that are different in many respects from the making of a flat fabric.
The Weave
The weave employed is an ordinary double cloth plain, made with
face, back, binder and gut. It is necessary to have 2 back, 2 binder, 4
face and 4 gut warps. The accompanying table will show the number
of threads required in each warp, together with the weights carried
on each one.
WARP DETAILS FOR VAN HEUSEN COLLAR
Method of Reeding
The front reed used is a 40 dent, with one cord or seven threads to
each dent. In some mills, however, great advantage has been found
in using a 26½ dent front reed, drawing 10 threads in one dent and
11 in the next, splitting between face and back, which makes the
stock work much easier, and relatively increases the output. Any
tendency to “rowing” caused by the dents in this coarser reed are
completely hidden in the bleaching process.
The folding line between the neck band and the outer fold of the
collar is made by leaving out the binder and gut threads in four cords
at the desired point, only retaining the face and back threads. The
position of the folding line may be varied in each of the three
standard widths to meet the requirements of the manufacturer and
according to the style of the collar desired.
There are 104 picks per inch, counting at the folded line, as there
are more on the short side and less on the long side. High grade
60/2 C. P. yarn is used throughout. The goods are woven in the gray
and bleached afterwards.
Knitted Narrow Fabrics
By William Davis, M.A.
Branch of the Knitting Industry That Presents Interesting Features—
Yarn Testing—Manufacture of Cleaners and Meat Bags, Coverings
for Wires and Cables, Fancy Stitch and Colored Effects for
Trimmings—Use of Core Thread to Give Strength
Knitting machine builders are remarkable for the new inventions
and adaptations they are constantly bringing out on their machines.
Several important concerns in this line have recently been active in
producing types to deal with the large trade now being done in
narrow fabrics for various purposes.
The ordinary circular knitting machine of small diameter has long
been recognized as a suitable means of making trials of new yarns
to judge how closely they match the original sample, because in
knitting there is not the necessity of elaborate warp preparation and
loom mounting. The machine generally employed for this purpose is
an ordinary type of stocking knitter containing 96 or 112 needles. If
the machine is only to be employed as a sampling machine it is by
no means necessary to have a full stocking machine, because in this
work it is never necessary to use the ribber or dial which is always
supplied.
The work of sampling to shade is done in most weaving or
spinning factories and a narrow width plain stitch knitting machine is
satisfactory for the purpose. It is usually quite suitable to work the
machine by hand, owing to the small lengths required and the
frequent changes necessary when testing different colors and
qualities.
The latch needle machine is much better for this purpose than the
bearded needle frame owing to the simplicity of loop formation and
also owing to the facility with which small or thick yarns can be made
to give good work on the machine with suitable adjustment of the
stitch tensions. It is also used as a means of producing samples of
color, as the various colors can be introduced rapidly one after the
other on this machine.
This type of frame with the needles stationary, and revolving cams
and thread guide has from the first been recognized as the best
adapted for knitting gas mantles from ramie. The yarn is working in
long lengths on a narrow width circular knitting machine using the
latch needle and this fabric is afterwards cut into lengths according
to the mantles being produced. Mantles of different sizes can be
obtained by using different diameters of machines as supplied by
machine builders for this purpose.
In most hardware establishments and department stores one sees
woven metal material knitted into fabric on such machines, and
intended to be used for cleaning pots and pans in household work.
The wire has a sharp edge so as to grip the matter to be removed.
Knitting the metal material into looped form enables the product to
do its work with the greatest efficiency.
Another side line of the knitting industry is the production of what
are known as meat bags, with which the carcasses of frozen and
ordinary mutton and beef are covered prior to transport. These bags
are usually made on circular knitting machines of large diameter
using the latch needle, and as the size of the yarn is fine compared
to the set of the needles a gauze-like character is obtained which
allows free circulation of air as well as affording a clean method of
handling the meat and protecting it in the course of transport on ship,
train and truck.
Fig. 3 Fig. 4
It is evident that this tubing can be used for the purpose of
covering wires and cables which slide inside the fabric. It has more
elasticity than woven fabric of similar form and is generally produced
in a more simple and direct manner. It should be pointed out,
however, that this fabric is susceptible to being torn and if it breaks at
any point a little further strain will cause it to unravel in a rapid
manner. Thus it is clear that it cannot be used by itself to any great
extent in cases where great strain or pull will be applied to it. Made in
suitable materials, there is nothing to hinder this tube from serving as
lamp wicks.
Fig. 7 Fig. 8
Knitted Cords
Fig. 6 gives a view of a narrow fabric made on a circular latch
needle knitting machine with only six needles in the cylinder. There
are two feeds, one supplying blue yarn to the needles and the other
supplying green, the pattern being alternate courses of green and
blue. The material is artificial silk and the cord, for it is nothing more,
is employed for threading through certain garments which have a
kind of open trimming through the spaces of which this cord is
passed to complete the drawing together of the part. Very often
these drawing together cords are provided with tassels at their
extreme ends to afford a further ornamental feature.
Fig. 7 gives another variation of this pattern produced on the same
machine where the courses alternate with each other in red and
green. This sample shows the facility with which new color blends
can be produced to match any color of ground garment. One bobbin
is simply replaced with another on the machine, or both may be
changed. In this pattern again a decided tendency is shown for the
effect to run in the direction of the right owing to the tendency to a
spiral effect.
Updated editions will replace the previous one—the old editions will
be renamed.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the terms
of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com