Problem
In server.js's pinoHttp({ ... }) block, two require() calls live inside per-request callbacks:
genReqId: (req, res) => {
...
: require('crypto').randomUUID();
...
},
serializers: {
req: (req) => ({
...
url: require('./app/middleware/redact-url.js').redactUrl(req.url),
...
}),
},
Node caches require() results so the cost is just a hashmap lookup — not a real perf hit — but every other import in server.js is hoisted to the top-of-file block, and these two stick out as inline. They belong with the rest of the imports.
Fix
Hoist both to the module-top block. Switch the crypto import to node:crypto (preferred explicit form for built-ins).
Acceptance
Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/
Problem
In
server.js'spinoHttp({ ... })block, tworequire()calls live inside per-request callbacks:Node caches
require()results so the cost is just a hashmap lookup — not a real perf hit — but every other import inserver.jsis hoisted to the top-of-file block, and these two stick out as inline. They belong with the rest of the imports.Fix
Hoist both to the module-top block. Switch the crypto import to
node:crypto(preferred explicit form for built-ins).Acceptance
cryptoandredactUrlimported at the top ofserver.jsrequire()calls inside the pinoHttp configProudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/