-
Book Overview & Buying
-
Table Of Contents
Full-Stack Web Development with TypeScript 5
By :
To develop a working application, we will need to store our data somewhere. In this section, we will define the interfaces we are going to use for our storage and create an in-memory implementation of our storage for users, chats, and messages. In-memory storage is a method of storing data directly in the main memory (RAM) of a computer. Because data stored in memory is volatile, it’s lost when the application stops.
Let’s start this process by defining the data interfaces that we are going to use in our database classes. In the following code, we will create the structure of all the objects that we are going to use when we interact with the database:
src/models/db.ts
export type Email = `${string}@${string}.${string}`; This line defines a custom type named Email. It uses template literal types to ensure that any string matching this type must follow the conventional email format: a string, followed...