Taran Bains
TILBLOGABOUTUSES

Today I learned about...
backend

Back to all tags

09.09.2024backend

orbstack

TIL about orbstack — a fast and lightweight way to run containers on a Mac!

So I’ve been trying to add in some cache-control headers to my remix site and I’m using cloudflare as my CDN.

In order to determine if the cache is being hit, cloudflare adds a cf-cache-status header to the response. You can find out more about it in the below blog post!

Read more

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.

Check out supertest when you’re doing api development :)

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 😆

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

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               |   |                    |
|  |                  |  |                  |   |                    |
|  |                  <--+                  |   |                    |
|  |                  +-->                  |   |                    |
|  |                  |  |                  |   |<-------------------+
|  |                  |  |                  |   |
|  +------------------+  +------------------+   |
|                                               |
+-----------------------------------------------+