VoidGen is a lightweight, configurable mock API server that generates RESTful endpoints from JSON and other structured data formats. It is designed for frontend development, testing, rapid prototyping, and any scenario where you need a reliable API without building a full backend.
- Instant REST API from JSON files (with additional data formats planned)
- Supports both singleton and collection resources
- In-memory data store with automatic reload on file changes
- Full CRUD operations for collection resources
- Configurable port and data file
- Tested with Jest
# Using npm
npm install -g voidgen
# Or using yarn
yarn global add voidgen
# Or using pnpm
pnpm add -g voidgenvoidgen --file path/to/your/data.json --port 3000Your JSON data file should follow this structure. While JSON is currently the only supported format, future updates will introduce support for other data and schema formats.
{
"todos": [
{ "id": 1, "title": "Learn TypeScript", "completed": false },
{ "id": 2, "title": "Build something awesome", "completed": true }
],
"config": {
"theme": "dark",
"notifications": true
}
}This will generate the following endpoints:
GET /api/todos- Get all todosGET /api/todos/:id- Get a specific todoPOST /api/todos- Create a new todoPUT /api/todos/:id- Replace a todoPATCH /api/todos/:id- Partially update a todoDELETE /api/todos/:id- Delete a todoGET /api/config- Get configPUT /api/config- Replace configPATCH /api/config- Partially update config
- Node.js 16+
- pnpm (recommended) or npm/yarn
- Clone the repository
- Install dependencies:
pnpm installpnpm dev- Start development server with hot-reloadpnpm build- Build the projectpnpm start- Start the production serverpnpm test- Run testspnpm test:watch- Run tests in watch modepnpm test:coverage- Generate test coverage reportpnpm lint- Run ESLintpnpm format- Format code with Prettier
Run the test suite:
pnpm testVoidGen is actively evolving. Planned enhancements include:
- REST API generation from OpenAPI specifications
- REST API generation from TypeScript interfaces
- Automatic random/mock data generation
- Advanced route-level behavior (latency, error injection, rate limiting)
- Persistent storage options (file or SQLite)
- Relationship modeling between resources
- Web interface for browsing and editing data
For the full roadmap, see:
Contributions are welcome! Please feel free to submit a Pull Request.