Converting callbacks to promises

It’s easier to work with Promises (or Async/await) compared to callbacks. This is especially true when you work in Node-based environments. Unfortunately, most Node APIs are written with callbacks.

Today I want to show you how to convert callbacks to promises.

Three useful Express middleware

As I created applications with Express and Node, I learned about three useful middlewares:

  1. Morgan
  2. Camelcase
  3. Remove empty properties

Of these three, Morgan is an actual middleware. You can download Morgan from npm directly. The other two are middlewares I created with camelcase-keys and omit-empty respectively.

I want to share what these three middlewares do, and how they make life easier for me when I’m creating applications.

Inconsistent behavior among browsers when clicking on buttons

I noticed browsers were inconsistent in how they handle a click on <button>. Some browsers choose to focus on the button. Some browsers don’t.

In this article, I want to show you my test and findings. Then, I want to talk about a way to overcome these inconsistencies.

Dancing with Fear

Fears and doubt often pop into my head when I work.

When I code, I wonder:

  • Am I using best practices?
  • Did I structure code in the best possible way?
  • Am I doing it correctly?

When I write, I wonder:

  • What makes me qualified to teach anything?
  • Will people understand what I’m trying to say?

When I run my business, I wonder:

  • Should I reply to every single email?
  • Should I continue to focus on articles?
  • Can I see pre-orders for courses?
  • What if I can’t complete my courses on time?
  • Are my products and sales emails persuasive but not coming off too sales-y?

I hate having these thoughts because they make me hesitate. And I slow down in my work.

But I love these thoughts because they tell me I’m doing the right thing.

Seeding a database

When you write tests for the backend, you need to test for four different kinds of operations:

  1. Create (for adding things to the database)
  2. Read (for getting things from the database)
  3. Update (for changing the database)
  4. Delete (for deleting things from the database)

The easiest type to test for is create operations. You put something into the database and test whether it’s there.

For the other three types of operations, you need to put something into the database before you write the test.

Connecting Jest and Mongoose

The hard part about testing a backend application is setting up a test database. It can be complicated.

Today, I want to share how I setup Jest and Mongoose.

Endpoint testing with Jest and Supertest

I played around with testing lately. One thing I tried to do was to test the endpoints of my Express application.

Setting up the test was the hard part. People who write about tests don’t actually teach you how they set it up. I could not find any useful information about this, and I had to try and figure it out.

So today, I want to share the setup I created for myself. Hopefully, this can help you when you create your own tests.

How to setup a local MongoDB Connection

I always use MongoDB as a database when I work on an app. And I like to connect to a database on my computer because it speeds up dev and test-related work.

Today, I want to share how to create and connect to a local MongoDB Database.

Frontend vs Backend

I used to think it would be easy to write backend if I knew JavaScript. I thought it would be easy because Node is JavaScript. I didn’t have to learn a new language.

But I was wrong.

But backend was hard to learn. I took ages to learn it. (And I’m still trying to master it).

I realized I had problems learning backend because I thought Frontend and Backend were the same—they were just code.

That’s a big mistake.

Frontend and Backend are different beasts altogether. I had to respect their differences before I could learn Backend properly.

If I were to explain the difference between Frontend and Backend (in terms of implementation), I would say:

  • Frontend is about perception
  • Backend is about communication

Hold on while i sign you up…

Woohoo! You’re in!
Now, hold on while I redirect you.