Step 3

We will eventually store our notes in a database but for now let's simply keep them in an array.

Add the following to index.js:

const notes = [];
notes.push(new Note("Sample 1", "Author 1"));
notes.push(new Note("Sample 2", "Author 2"));
notes.push(new Note("Sample 3", "Author 3"));
console.log(notes);

Rerun the Express application again and ensure the samples are printed to the terminal.

Expected output
[
  Note { content: 'Sample 1', author: 'Author 1' },
  Note { content: 'Sample 2', author: 'Author 2' },
  Note { content: 'Sample 3', author: 'Author 3' }
]

It is going to be annoying if, during development, every time we change something in the code, we would need to stop the server and run it again.

Stop the application and install nodemon:

npm install -g nodemon

Nodemon is a utility that will monitor for any changes in your source and automatically restart your server.

I've decided to install it globally (the flag -g means install globally) since we will very likely use Nodemon for other projects.

After installation, instead of using node command, use nodemon to run your application:

nodemon index.js

Make a small change to your code and save the file. Notice the server is restarted automatically!