The routes directory contains two router modules. As it stands, each router module creates a router object, adds route functions to that object, and then assigns it to the module.exports field. That suggests we should export the router as the default export, but as we said earlier, that didn't work out right. Instead, we'll export router as a named export.
Change the filenames:
$ cd routes
$ mv index.js index.mjs
$ mv notes.js notes.mjs
Then, at the top of each, change the require statement block to the following:
import util from 'util';
import express from 'express';
import * as notes from '../models/notes-memory';
export const router = express.Router();
It will be the same in both files. Then, at the bottom of each file, delete the line assigning router to module.exports.
Let's turn to app.mjs and change how the router modules are imported.
Because router is a named export, by default you'd import the router object, in app.mjs, as follows:
import { router } from './routes/index';
But then we'd have a conflict since both modules define a router object. Instead, we changed the name of this object using an as clause:
import { router as index } from './routes/index';
import { router as notes } from './routes/notes';
The router object from each module is hence given a suitable name.