; Date: August 23, 2020
This is the introduction to a four-part series covering the territory just discussed. Look below for links too the individual articles. The application developed in these tutorials is a single page application supporting multiple simultaneous users, with TODO items stored in a database, and supporting pseudo-real-time interaction among multiple users using Socket.IO.
This project demonstrates several things:
- Using Node.js to develop software, while using new features in Node.js 14
- Using Express, Bootstrap and Nunjucks to develop a web application
- Doing DOM manipulation in a Bootstrap application without using jQuery
- Pseudo-real-time application development using Socket.IO
- Using Sequelize to interface with SQL databases, and a method of easily switching between databases by switching configuration files.
In Project setup for Node.js 14, Express, Bootstrap v5, Socket.IO application -- we go over initializing a Node.js project directory, installing the required packages, and setting up the structure of an Express application. We start with using npm (or Yarn) to initialize the project, and then install the required packages. We then turn to wiring together an Express application, the database interface, and Socket.IO.
The application is written using ES6 modules, since they are so important to understand, and since Node.js 14 supports them. Another new feature is the ability to use async code in the top level of a Node.js module, and this application contains an example. For more discussion on what that means, see Node.js Script writers: Top-level async/await now available
In Using Sequelize for the database layer in an Express Node.js 14 application -- we go over using Sequelize to interface with an SQL database engine, to define a database schema, and to access (read/write/update/delete) data stored in an SQL database. Sequelize is a powerful ORM for SQL databases, with support for several SQL engines. In this example we will use SQLite3 because it is the simplest to set up. We also show that, with a simple configuration file change, it can use any of the databases supported by Sequelize, like MySQL.
In Using Bootstrap and Socket.IO for the user interface in an Express Node.js 14 application - we create a pseudo-real-time user interface using Bootstrap v5 and Socket.IO. We are using Bootstrap v5 because the first alpha was just launched and signals a major direction change in app development by dropping the requirement to use jQuery. As the version number bump from v4.5.x to v5 suggests, it is a major release with incompatible changes.
Socket.IO is a framework for semi-pseudo-sort-of-real-time data exchange between a client and Node.js code on a server. It has an event-oriented API for sending messages back and forth. In the TODO application we use this instead of a normal AJAX approach. It also lets us support multiple simultaneous users with the Todo application. Any update to the TODO list is automatically displayed on any other browser connected to the application.
In Running the TODO application - we go over how to run the finished application. This starts with installing the required dependencies, then adding a
start script to
package.json. After that we exercised the application to verify everything is working.
Because Sequelize makes it easy to switch between SQL databases, we installed a MySQL instance in Docker. After that we created a suitable configuration file, reran the application, and saw that it came right up on the new database. Then, switching between the databases is simply a matter of switching configuration files.
To learn about the project setup: Project setup for Node.js 14, Express, Bootstrap v5, Socket.IO application
To learn about the database setup: Using Sequelize for the database layer in an Express Node.js 14 application
To learn about the Bootstrap user interface: Using Bootstrap and Socket.IO for the user interface in an Express Node.js 14 application
To learn about running the Todo application: Running the TODO application
To return to the project overview: Single page multi-user application with Express, Bootstrap v5, Socket.IO, Sequelize