In terms of the server running locally, this can be started locally via the terminal with 'nodemon' (short for Node monitor) using command 'npm run server' and is found in the browser with url 'https://localhost:3000'. The server code begins with
server.js which starts the server and which uses
app.js to create the details. There are two important parts to
index const which deals with routes and the reference to static content in 'dist'.
The static content in 'dist' is of course where the browser code is found - and so the server knows where to 'serve' the webpage from.
index is where the server code is pulled together, using ./routes/index.js'.
○ There is a list of routes, which are variously called 'URLs', 'endpoints' and 'an API'. Strictly an API is a collection of URLs or endpoints which provide some functionality. In this case, the API gives access to our server which is what manages the link to the database. In this way, the database is protected from external attack (you have to sign-in to get in), the logic to handle database actions is controlled and can be changed independently of the PT website. For example, we could switch to a different database and the website would not even know.
○ The routes are defined as GET and POST options, which signify requests for (GET) or submission of (POST) data.
Each route has an associated function, which provides data security checks and carries out the requested actions.