https://github.com/tankengine-ish/express.js_api
Express.js API [personal project]
https://github.com/tankengine-ish/express.js_api
Last synced: about 1 year ago
JSON representation
Express.js API [personal project]
- Host: GitHub
- URL: https://github.com/tankengine-ish/express.js_api
- Owner: TankEngine-ish
- Created: 2024-01-07T21:03:45.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-11T14:43:54.000Z (over 2 years ago)
- Last Synced: 2024-01-12T04:36:48.550Z (over 2 years ago)
- Language: JavaScript
- Size: 1.06 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Express.js_API
For my first RESTful API I used Node/Express, the nodemon package to save time on restarting the server,
Postman to test my endpoints, Handlebars as the templating engine and some basic html and css.
## The MVC pattern
The MVC design pattern is a popular choice among developers using Express for structuring their applications. In simplified terms:
The Controller processes the user's request and then manipulates the model accordingly.
For example: interacting with the Model to perform operations on the data, and sending the appropriate response.
The Model is a representation of how the Express application sees the data.
It involves defining data models and handling interactions with the database.
The View is how the data from the model is being presented back to the user. This is where React might step-in and take control.
A simple diagram of the model:

MVC is meant to simplify our code and make it easier to read, update and improve, although Express is
not opinionated and doesn't enforce the MVC structure.
## Testing with Postman
It's worth noting that there's always a slight difference between the request time
that shows on our log inside the terminal and the log inside Postman. The reason is that
it simply takes more time for the response to make it back all the way to Postman.
![Alt text]()
In the shot above I was testing whether the endpoint was serving the static image content.
## REST design and principles
![Alt text]()