Transitioning from the PG to the Application
The PG is a rich, robust, and extensible way to quickly get started writing and running code, but our application has different needs from the PG that we will need to account for and fulfill. We want to make sure that our code is both easy to change and easy to understand, but fortunately, there are small steps we can take that will make a large difference later on.
Creating the Engine Instance
Now, the immediate question is this: how do we take our plucky snippet here and plug it into our application without turning it into an exercise in both masochism and self-discipline? The secret lies in preparation. When we built our PG snippet, we structured logic as atomically as possible into various discrete functions, which have all their dependencies passed in as parameters. This will help us “lift-and-shift” the code into our application. First, though, we need to add some code to our index.js
that will take the place of...