I’ve been a frontend developer for almost 6 years now and in this time I came to realise that having a clear image of both the backend and the frontend sides of a project would help in having a holistic understanding of it. Several months ago I decided to acquire some back-end skills, mainly because I wanted to become a more independent developer and have a better understanding of the business logic of any project that I might be working on.

I started with a course on frontendmasters, held by Scott Moss, in which he explains exactly how to create a simple and testable API with Express, a Node.js framework, and some of the best practices for it, along with specific technologies, like jwt and Mongo.

I’ll explain some of the initial steps and dive deeper into things that were new to me too.

To create a Node app, we’ll create a new folder and in the terminal run npm init for that folder and set it up by following the initial steps.

After going through those steps, create a new file called index.js in which we’ll write our code. All you need to start a simple app with Express is:

Simple hello world app

Express Hello World app

Supposedly we’d want to create an API that lets us perform all CRUD operations on some products into a database, just like an online shop.

From an architectural point of view, we can split it into three main categories or types of resources:

  • Models — the form that an entity has in our database
  • Controllers — here we define different actions that can be performed on the entities in our database
  • Routers — associating each route with the proper controller

#javascript #react #node #web-development

How to Make simple Shop App with Node.js and React
11.60 GEEK