Cuando estamos trabajando con promesas en Javascript, hay dos términos que se confunden muy a menudo: fulfill y resolve.
De acuerdo con el diccionario:
Eso es todo lo que necesitamos para resolver toda la confusión alrededor de estos dos términos que tendemos a usar indistintamente.
Echemos un vistazo al siguiente snippet de código como un ejemplo:
De acuerdo a la definición de “Promise”, el método resolve
puede recibir, ya sea un valor o un objeto…
As for today, we have several options to host our application, the big providers always offer solutions that fit our needs and try to make our lives easier.
In a world where we have a lot of offers, how do we select the right one for our case? With the past of time, we’ve got some experience on this topic and we’ll love to share it with you.
We should admit the there is a difference between a monolithic application and another one based on microservices, and we are not talking just about performance or specific requirements, we talk about…
When we talk about distributed systems we have to think about availability and load distribution all across our servers. While the replica pattern is important in this matter, to split our services in “shards” is something that can help us to maintain a good level of service for our users.
Let’s suppose that we have a service with 3 big components or 3 big parts that compound it. Each component has a different usage load and its performance impacts differently to the app in general.
If we use replicas for this our service, we can improve the availability time but…
Commonly, when we work with MongoDB and want to retrieve documents from a collection we make use of the method find or a variation combined with some kind of filtering or processing on the code side.
For most cases, the previous technique is going to be good enough, but there will be some other cases where that won’t be enough. For instance:
When we are facing any…
When we are working with Promises in Javascript, there are two terms commonly confused: fulfill and resolve.
According to the dictionary:
That’s everything we need to solve all the mess around these terms that we tend to use indistinctly.
Let’s take the next code snippet as an example:
According to the definition of Promise, the method resolve
can receive either a value or a thenable
object (an object with a method called…
When we are developing our business, we commonly tend to think about the core idea, aggregates and the payment model. In the beginning, it works well because the mindset of producing an MVP first and then iterate has been distributed in the entrepreneurship model.
Unfortunately, sometimes our products or services don’t have as much traction as we would like them to. A lot of times it doesn’t depend on the quality or the desirability of what we offer. It simply depends on the value that we are offering to our clients.
As for today, the main marketing strategy is to…
Starting to work in a team is hard for some of us. In the beginning, we are (badly) used to work alone and to know everything about the project we are working on (basically because we built it completely).
So if it’s the first time you’ll work on a project with other people, please take these tips in the count before you start.
One thing that we’ve learned with the time is that your perspective is your reality. The same rule applies to a team. When your team is new or you are the new guy in a team, it’s…
As the title says, today’s post is about how to generate a PDF file based on HTML content, all in Node.js.
To generate PDF files for reports or downloadable content is very common in a certain type of applications where those documents play the role of reports or receipts for a transaction. Unfortunately, while some documents are basically plain text, others require a more complex structure to display all that data. If that’s the case, you can get help with HTML and transform that into a PDF file.
What we are going to need:
Sometimes we have HTML files with content that depends on the environment or a variable in order to render specific content and send it to the browser. A natural way to handle this type of use cases is by using a server-side rendering library like handlebars or pug. Unfortunately, to include these libraries is not always possible or we don’t want to set up the project to support them.
If that’s the case (as it was for us) you’ll find the package string-replace-middleware very useful.
The core value of this package is to add the ability to replace simple strings…
These days, document your API is a great idea if you:
In case you are working with Node.js, we like to use the solution offered by apidoc https://www.npmjs.com/package/apidoc
The documentation generated by this package is not automatic so that you’ll have to describe your API resources. This may look like a tedious process, but the level of detail gained is incredible.