Configure API mocks with .roadhogrc.mock.js
masterWhen running roadhog dev, you can define mock APIs in a .roadhogrc.mock.js file. The API follows the Express@4 pattern.
Supported formats:
- Object/Array: Map a path to a static response.
- Custom Functions: Use a function
(req, res) => { ... }for dynamic logic. - Path shorthand: You can omit the HTTP method (e.g.,
GETorPOST).
export default {
// Support type as Object and Array
'GET /api/users': { users: [1,2] },
// Method like GET or POST can be omitted
'/api/users/1': { id: 1 },
// Support for custom functions, the API is the same as express@4
'POST /api/users/create': (req, res) => { res.end('OK'); },
};