7d55580d87
Split the 5,441-line index.js into an 86-line bootstrap, thin domain
route modules, shared lib/ helpers, and a repo/ layer that isolates the
DEV_MOCK branches (repo/*.mock.js). Repo methods return {statusCode, body};
routes are one-line wrappers. Pin search_path to "transit.bus" and
document the /bus/ prefix with legacy root aliases (Deprecation header).
Parity verified: 57/57 byte-identical on the stub differential harness
plus 24/24 live read-only responses vs the original against real
PostgreSQL. The only intentional behavior change: mock reorder/delete
bus-line endpoints no longer require a live DB (previously 500 in
DEV_MOCK=1 without PG). DEV_MOCK gate and node --check clean.
30 lines
741 B
JavaScript
30 lines
741 B
JavaScript
const { ERROR_LOG_API_URL } = require("./env");
|
|
|
|
|
|
async function reportError({ partofservice, error }) {
|
|
try {
|
|
await fetch(ERROR_LOG_API_URL, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
"x-internal-api-key": process.env.INTERNAL_API_KEY || "",
|
|
},
|
|
body: JSON.stringify({
|
|
service: "transit_api",
|
|
partofservice,
|
|
error,
|
|
}),
|
|
});
|
|
} catch (_) {}
|
|
}
|
|
|
|
|
|
function reportUnhandled(context, err) {
|
|
const message = err?.message || String(err);
|
|
const stack = err?.stack || message;
|
|
log("error", context, { error: message, stack });
|
|
void reportError({ partofservice: context, error: stack });
|
|
}
|
|
|
|
module.exports = { reportError, reportUnhandled };
|