In package.json, add this to the scripts section:
"start-fs": "DEBUG=notes:* NOTES_MODEL=fs node --experimental-modules ./bin/www.mjs",
With this code in place, we can now run the Notes application as follows:
$ DEBUG=notes:* npm run start-fs
> notes@0.0.0 start-fs /Users/david/chap07/notes
> NOTES_MODEL=models/notes-fs node --experimental-modules./bin/www.mjs
notes:server Listening on port 3000 +0ms
notes:fs-model keylist dir=notes-fs-data files=[ ] +4s
Then we can use the application at http://localhost:3000 as before. Because we did not change any template or CSS files, the application will look exactly as you left it at the end of Chapter 6, Implementing the Mobile-First Paradigm.
Because debugging is turned on for notes:*, we'll see a log of whatever the Notes application is doing. It's easy to turn this off simply by not setting the DEBUG variable.
You can now kill and restart the Notes application and see the exact same notes. You can also edit the notes at the command line using regular text editors such as vi. You can now start multiple servers on different ports and see exactly the same notes:
"server1": "NOTES_MODEL=fs PORT=3001 node --experimental-modules./bin/www.mjs", "server2": "NOTES_MODEL=fs PORT=3002 node --experimental-modules./bin/www.mjs",
Then you start server1 and server2 in separate command windows as we did in Chapter 5, Your First Express Application. Then, visit the two servers in separate browser windows, and you will see that both browser windows show the same notes.
The final check is to create a note where the key has a / character. Remember that the key is used to generate the filename where we store the note, and therefore the key cannot contain a / character. With the browser open, click on ADD Note and enter a note, ensuring that you use a / character in the key field. On clicking the Submit button, you'll see an error saying that this isn't allowed.