const { DEV_MOCK } = require("../lib/env"); // The repository layer merges every domain's PostgreSQL implementation with the // mock implementations. In DEV_MOCK mode the mock methods (which read the // in-memory `mock/store`) shadow the DB-backed ones; endpoints that have no // mock branch always use the PostgreSQL implementation, exactly as the original // handlers did. // // Every method takes the Express `req` (the original handlers read params, // query, body and user from it) and returns `{ statusCode, body }`. Route // handlers only transform that into `res.status(...).json(...)`. const pg = { ...require("./stops"), ...require("./lines"), ...require("./fleet"), ...require("./drivers"), ...require("./daily"), ...require("./weekly"), ...require("./adminSchedules"), ...require("./schedules"), ...require("./route"), ...require("./navigation"), ...require("./gps"), }; const mock = { ...require("./stops.mock"), ...require("./lines.mock"), ...require("./fleet.mock"), ...require("./drivers.mock"), ...require("./adminSchedules.mock"), ...require("./schedules.mock"), }; module.exports = DEV_MOCK ? { ...pg, ...mock } : pg;