In the last section, we put together all this source code that we're going to need right now for the
worker project.
Again, the worker is what's going to watch this any time that we get a new index inserted into lettuce.
The worker will automatically pull the value out and calculate the appropriate Fibonacci value for it
and then insert that value back into lettuce.
We're going to start putting together the code for the express server as a quick reminder, if you don't
want to go through any this JavaScript specific setup.
You can always move on to the next section and you'll find all the source code that we're writing inside
that section.
So all you have to do is download the file there and unzip it into your project.
I'm only walking you through all the source code right now, in case you're kind of curious about how
to write a JavaScript application that makes use of all these different pieces.
So let's get started on the express server that's going to serve as the sort of API layer that communicates
with Redis and Postgres and communicates information over to a running React application.
So back inside my code editor, we were just working inside that worker directory.
I'm not going to make a second directory that I'm going to call server and this thing is going to house
all the code for our server, the express server that's going to function as the API.
Now quick note here, please make sure that you make the server directory next to or as a sibling to
the worker folder.
You do not want to place the folder inside of the worker process.
Don't want that.
So it needs to be outside in a separate sibling folder.
Now, inside of your will get started by making a package JSON file.
We're going to have a couple of different dependencies and a couple of different scripts as well.
So we'll first liftoff or liftoff, excuse me, the different dependencies that our project is going
to have.
So for dependencies, we're going to get express at version four point one six point three.
We're going to get a PostgreSQL client at seven point four point three.
We're going to get a reticent client at two point eight point zero.
We'll get a course installation at two point eight point four.
And we'll get no money as well for development purposes.
At one point one, eight point three.
Like so and again, we'll talk about why we are installing Node one as we start to put together the
darker side of this project.
And next to the dependencies, I'm going to also define a script section.
Very similar to the worker process, we're going to have a development script or a dev script that runs
Snowden.
And then we will also have a start scripts for node index dodgers.
All right, as usual, please double check, make sure that you've got your commas after each one of
these lines and make sure you've got double quotes everywhere inside of here.
Need double quotes everywhere?
So once we've got the package that Jason File all put together of delete this next time we close the
file, not delete it, my mistake?
And then inside the server directory, we're going to make another file called Keys Dogs.
And just like before this file is going to house some other different variables that we're going to
need to connect to the running instance of redness and the running instance of PostgreSQL that will
be associated with our application.
So inside of the key, such as file, I'll say, module exports and then inside of here, we're going
to have a pretty good different number of pieces of configuration.
So please again, double check your typing in here because we're going to do a lot of typing.
I'll first do a Redis host that's going to come from the environment variable process that EMV Typekit
Redis host.
We'll get a read a sport.
We will get a PGA user, so this is the PostgreSQL user that we're going to log in as from process.
Ian Vidot PGA user.
There were PG host.
We'll do a PG database, this is going to be the name of the database inside of progress that we're
going to connect to.
E.g., database.
We'll get a password.
As you might guess, this is the password to the database, which we're going to have to define at some
point.
So password.
We get a PG port.
Like so as well, we should see one, two three four, five, six seven entries inside of here.
Now I got to ask you at this point again, please make sure that all of these environment variable names
are capitalized.
So you should see capital use user capital PEG, host, capital PEG database and so on.
And also double check all the keys on the left hand side as well.
You make a typo inside this file.
It's going to be a little bit of a pain to track down in the future, so please just do a quick double
check inside of your ID.
Make sure you've got the correct spelling for stuff like, say, database on both sides in the correct
spelling for password on both sides and so on.
All right.
Let's take a quick pause right here.
We're going to come back the next section and continue working on our server implementation.
So I'll see you in just a moment.