Nodejs


How to Upload Files with Multer

Uploading files is an essential feature for web applications these days. This tutorial will cover how to upload files into a server from the browser as well as create an API with Node.js to handle those uploads.

To simplify everything, we are going to use Express to build our API. And to handle file uploads, we are going to use Multer. Multer is an official Express middleware for handling multipart/form-data requests, which primarily used to upload files.

Read more


How to Use GraphQL DataLoader

GraphQL offers a very convenient way to handle database relations. But with this simplicity comes with an issue that actually easy to fix, but sometimes people forget about it. And that issue is known as the “N+1” problem. In this tutorial, we will learn on how to fix this problem using DataLoader.

Getting Started

The only thing we need to get started with this project is a blank folder with npm package initialized. So, lets create one!

Read more


How to Build a REST API with Express and Mongoose

This tutorial will guide you to build a RESTful API with Node.js, Express, and Mongoose with CRUD functionalities. I expect that you have the basic knowledge of Node.js and JavaScript. If you do, you’re good to go!

Prerequisites

These software need to be installed on your machine first:

Getting Started

The only thing we need to get started with this project is a blank folder with npm package initialized. So, let’s create one!

Read more


How to Build a Realtime Chat App with Node.js

In this tutorial, we are going to build a basic chat application with Node.js. Before we get started, I assume that you have little bit knowledge of JavaScript and Node.js.

Here, we will be using an awesome tool called Socket.io. If you don’t know what that is, basically it’s a JavaScript library that allows you to handle realtime data on front-end and back-end side. We also going to use Express which is by far the most popular Node.js framework for building web-based applications.

Read more


How to Test Your Express API with SuperTest

Express is the most popular Node.js framework for building web applications, especially REST APIs. And in this article, I’m going to show you how you can test your API endpoints with a cool library called SuperTest.

SuperTest is an HTTP assertions library that allows you to test your Node.js HTTP servers. It is built on top of SuperAgent library, wich is an HTTP client for Node.js.

Getting Started

The best way to learn how to write tests is by testing an existing app. So, in this tutorial we’re going to use the blog REST API I built using Express and Mongoose which you can read more in this article. You can clone the repo onto your computer using the command below.

Read more


Build Server Rendered React App from Scratch

If you have played around with React for a while, and you are planning to build a production web app, you may need to consider the performance and SEO for your web app. And that problem can be solved by server-side rendering. Even there are many different approach to achieve better performance on client-side rendering, it might not be a good solution for low-powered devices such as an old phone.

What makes it so fast?

On the client-side rendering, also known as single page app, A typical response sent by the server when requesting a React site will look something like this:

Read more