Backend


Back to Tags

express-middleware

🗓️ June 03, 2020

Express middleware is broken up into different types based on the number of arguments your middleware function takes. A middleware function that takes 4 arguments is classified as “error handling middleware”, and will only get called if an error occurs.

Model vs Controller

🗓️ April 21, 2020

After a brief conversation with Darnell, TIL that a controller should only be concerned with the processing of a request. Database logic etc. should live in the Model.

I’m such a noob 😆

Hypermedia 🤔

🗓️ October 22, 2019

In the Rest maturity model, Hypermedia is considered to be the most mature — the highest level.

  1. The swamp of Pox (XML)
  2. Resources
  3. HTTP Verbs
  4. Hypermedia

In a nutshell, Hypermedia has REST endpoints expose links to other related data. For instance, if there was an endpoint that existed to fetch all the products in a particular catalog, each product resource in the payload would have a _links property that had attributes that would allow users of the API via self to navigate to the respected product. Just by visiting products, I’d have a way of getting to a specific product without having to store the API endpoint in my source code; the initial API call would prove it to me.

{
  "_embedded": {
    "products": [
      {
        "title": "Navy blue stone wash jeans",
        "seller": "Revtown Jeans",
        "_links": {
          "self": {
            "href": "/products/42"
          }
        }
      }
      // more products ...
    ]
  }
}
Read More

A taste of Node

🗓️ August 10, 2019

Node is super useful for doing high throughput low latency I/O tasks! Here’s a diagram that roughly describes how Node works (I omitted libuv but you can bet it’s there):

Server/A machine                                               World/Another machine
+-----------------------------------------------+              +-------------+
| +-------------+                               |              |             |
| |JS           |                               |              |             |
| |             |                               +-------------->             |
| |             |                               |              |             |
| |             |                               |              |             |
| |             |                               |              +-----+-------+
| +---+--^------+                               |                    |
|     |  |                                      |                    |
|     |  |                                      |                    |
|     |  |                                      |                    |
|     |  |                                      |                    |
|     |  |                                      |                    |
|  +--v--+------------+  +------------------+   |                    |
|  |Node (C++)        |  |OSS               |   |                    |
|  |                  |  |                  |   |                    |
|  |                  <--+                  |   |                    |
|  |                  +-->                  |   |                    |
|  |                  |  |                  |   |<-------------------+
|  |                  |  |                  |   |
|  +------------------+  +------------------+   |
|                                               |
+-----------------------------------------------+