DEV Community

Olasunkanmi Igbasan
Olasunkanmi Igbasan

Posted on • Updated on

Building a simple REST api with Express: A walkthrough.

Project Description
This article is meant for developers and other technical audiences, looking to understand the implementation of a blogging app or any app really with the Express framework. Furthermore, this article is organized in a way that would cover the main areas of the project such as the technical requirements, design and implementation, challenges, deployment and testing and conclusion.

This project is a web application using Node.js, Express, and MySQL, It also demonstrates a one-to-many SQL relationship.

Technology Stack

  • server side : Node.js, Express.js

  • Database: MySQL

Prerequisites

  • Basic knowledge of JavaScript, and SQL.
  • MySQL server, Node.js and npm installed on your Machine.

Step 1: Setting up the server

  • Create a new directory for the project.
  • Navigate to the terminal of the directory.
  • Initialize a new Node.js project with the code below
`npm init -y`
Enter fullscreen mode Exit fullscreen mode

Install the following dependencies

nodemon - nodemon is a tool that helps develop node-based applications by automatically restarting the node application when file changes in the directory are detected.

Express - Express is a free and open-source Node.js web application framework.

bcrypt - bcrypt turns a simple password into fixed-length characters called a hash.

body-parser - body-parser is the Node.js body parsing middleware.

crypto-js - crypto-js is a module in Node. js which deals with an algorithm that performs data encryption and decryption.

dotenv - The dotenv package is a great way to keep passwords, API keys, and other sensitive data out of your code.

express-rate-limit - express-rate-limiting is a strategy you can use to control traffic on a network, secure backend API and limits the number of unwanted requests that a user can make within a specific time frame.

helmet - helmet fills in the gap between Node.js and Express.js by securing HTTP headers that are returned by your Express apps.

joi - joi is used for schema description and data validation.

joi-password - joi-password is an extension of joi that helps in validating passwords.

jsonwebtoken - Often called JWT, or JSON Web Token. JWTs are mainly used for authentication. After a user signs in to an application, the application then assigns JWT to that user.

morgan - morgan is a Node. js and Express middleware to log(taking records of events that occur in a software) HTTP requests and errors, and simplifies the process.

winston - winston is designed to be a simple and universal logging library with support for multiple transports.

Top comments (0)