Now that we can store messages in the database, let's integrate this into the Notes router module.
In routes/notes.mjs, add this to the import statements:
import * as messages from '../models/messages-sequelize';
If you wish to implement a different data storage model for messages, you'll need to change this import statement. You should consider using an environment variable to specify the module name, as we've done elsewhere:
// Save incoming message to message pool, then broadcast it router.post('/make-comment', ensureAuthenticated, async (req, res, next) => { try { await messages.postMessage(req.body.from, req.body.namespace, req.body.message); res.status(200).json({ }); } catch(err) { res.status(500).end(err.stack); ...