Status Manifest (status-manifest.js)
Examine the in-memory route compilation registry, status cache accessors, and request middleware hook connectors.
Key File Location: ./dinou/core/status-manifest.js💡 Overview
During application execution, the Express routing server needs to know whether a requested route is compiled successfully (status 200), has triggered a redirect (status 302), or is missing.
The status-manifest.js utility provides a lightweight, in-memory registry (statusMap) to track the HTTP status codes generated during the static rendering passes of all pages.
📊 Manifest API Structure
The chart below traces the simple, high-performance key-value operations exposed by the manifest:
⚡ Role in the Server Lifecycle
Although simple, the Status Manifest performs key optimization work during route resolution:
- Bypass Read Overhead: Instead of parsing
metadata.jsonfiles from disk on every page view to check compile states, the main Express router queriesgetStatus(), reducing file system I/O bounds. - Mutations Checking: When background ISR or dynamic ISG compiles routes, they invoke
updateStatus(path, status). If the new status matches the cached code, the operation exits immediately to avoid triggering HMR reload notifications.
⚙️ Complete Code Walkthrough
Below is the full, complete code of status-manifest.js:
const statusMap = new Map(); // In-memory compilation status registry
function getStatus(reqPath) {
return statusMap.get(reqPath)?.status;
}
function updateStatus(reqPath, status) {
const current = statusMap.get(reqPath)?.status;
if (current === status) return; // Prevent unnecessary map updates
statusMap.set(reqPath, { status });
}
module.exports = { getStatus, updateStatus };