We'll use Express in this recipe, however, the particular way Express handles this case represents the norm across frameworks, and indeed the behavior corresponds to Node core functionality.
So let's create a tiny Express app, that shouts back whatever message we give it.
We'll create an app folder, initialize it as a package, install express, and create an index.js file:
$ mkdir app
$ cd app
$ npm init -y
$ npm install --save express
$ touch index.js
Our index.js file should look like the following:
const express = require('express')
const app = express()
app.get('/', (req, res) => {
pretendDbQuery(() => {
const yelling = (req.query.msg || '').toUpperCase()
res.send(yelling)
})
})
app.listen(3000)
function pretendDbQuery (cb) {
setTimeout(cb, 0)
}