{"id":25653272,"url":"https://github.com/akinoccc/jsonx-mock","last_synced_at":"2026-02-24T09:03:54.896Z","repository":{"id":277784784,"uuid":"932222525","full_name":"akinoccc/jsonx-mock","owner":"akinoccc","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-21T13:04:31.000Z","size":218,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-25T04:41:59.911Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akinoccc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-13T15:13:07.000Z","updated_at":"2025-02-19T15:41:42.000Z","dependencies_parsed_at":"2025-04-16T03:43:36.861Z","dependency_job_id":"c9757961-3946-4eda-b6ec-23f75e22c1bf","html_url":"https://github.com/akinoccc/jsonx-mock","commit_stats":null,"previous_names":["akinoccc/json-mock","akinoccc/jsonx-mock"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/akinoccc/jsonx-mock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akinoccc%2Fjsonx-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akinoccc%2Fjsonx-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akinoccc%2Fjsonx-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akinoccc%2Fjsonx-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akinoccc","download_url":"https://codeload.github.com/akinoccc/jsonx-mock/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akinoccc%2Fjsonx-mock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29777615,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T04:54:30.205Z","status":"ssl_error","status_checked_at":"2026-02-24T04:53:58.628Z","response_time":75,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-23T19:37:19.942Z","updated_at":"2026-02-24T09:03:49.882Z","avatar_url":"https://github.com/akinoccc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jsonx Mock\n\nA TypeScript-based Mock REST API Server with integrated authentication and validation. Perfect for rapid API prototyping and development.\n\n## Features\n\n- 🚀 **Auto-generated REST endpoints**\n- 🔒 **JWT Authentication middleware**\n- ✅ **Data validation** with Joi schemas\n- ⚡ **Dual usage mode** (CLI \u0026 Programmatic)\n- 📊 **Built-in pagination**\n- ⏱️ **Configurable response delays**\n- 🛠️ **Custom route support**\n\n## Installation\n\n```bash\nnpm install jsonx-mock --save-dev\n# or\nyarn add jsonx-mock -D\n# or\npnpm add jsonx-mock -D\n```\n\n## CLI Usage\n\n### Quick Start\n```bash\njsonx-mock --port 3000 --db-storage ./data/db.json --db-model ./models\n```\n\n### Command Options\n| Option               | Description                          | Default Value     |\n|----------------------|--------------------------------------|-------------------|\n| `-p, --port \u003cport\u003e`  | Set server port                      | 3000              |\n| `-d, --delay \u003cms\u003e`   | Add response delay in milliseconds   | 0                 |\n| `--db-storage \u003cpath\u003e`| Path to database storage file        | Required          |\n| `--db-model \u003cpath\u003e`  | Path to model definitions directory  | Required          |\n| `--help`             | Show help menu                       | -                 |\n\n### Configuration File\n\nSupports multiple configuration file formats (loaded by priority):\n\n```ts\n// mock.config.ts\nexport default {\n  port: 3000,\n  dbStoragePath: './data/db.json',\n  dbModelPath: './models',\n  auth: {\n    enabled: true,\n    secret: 'your-secret-key',\n    expiresIn: '1h'\n  }\n}\n```\n\n## Programmatic Usage\n\n### Basic Setup\n\n```ts\nimport MockServer from 'jsonx-mock'\n\nconst server = new MockServer({\n  port: 3000,\n  dbStoragePath: './data/db.json',\n  dbModelPath: './models',\n  auth: {\n    enabled: true,\n    secret: 'your-secret-key'\n  }\n})\n\nserver.start()\n```\n\n### Advanced Configuration\n\n```ts\ninterface Config {\n  port?: number // Server port (default: 3000)\n  delay?: number // Response delay in milliseconds\n  prefix?: string // API path prefix\n  dbStoragePath: string // Path to database storage file\n  dbModelPath: string // Path to model definitions\n  auth?: {\n    enabled: boolean // Enable JWT authentication\n    secret: string // JWT signing secret\n    expiresIn?: string // Token expiration time\n    excludePaths?: string[]// Public endpoints\n  }\n}\n```\n\n### Custom Extensions\n```ts\n// Add validation rules\nserver.addValidation('users', {\n  name: Joi.string().required(),\n  email: Joi.string().email().required()\n})\n\n// Add custom routes\nserver.addCustomRoute('get', '/system/health', (req, res) =\u003e {\n  res.json({ status: 'ok', timestamp: Date.now() })\n})\n\n// Add middleware\nserver.pre((req, res, next) =\u003e {\n  console.log(`[${new Date().toISOString()}] ${req.method} ${req.path}`)\n  next()\n})\n```\n\n## Core Functionality\n\n### Auto-generated Endpoints\n| Method | Endpoint              | Description          |\n|--------|-----------------------|----------------------|\n| GET    | /api/:resource       | List resources       |\n| GET    | /api/:resource/:id   | Get single resource  |\n| POST   | /api/:resource       | Create resource      |\n| PUT    | /api/:resource/:id   | Update resource      |\n| DELETE | /api/:resource/:id   | Delete resource      |\n\n### Authentication Flow\n```ts\n// Generate access token\napp.post('/auth/login', (req, res) =\u003e {\n  const token = server.generateToken({\n    userId: 123,\n    role: 'admin'\n  })\n  res.json({ token })\n})\n\n// Protected endpoint example\napp.get('/user/profile', (req, res) =\u003e {\n  const user = req.user // Parsed from JWT\n  res.json({\n    id: user.id,\n    name: 'Test User'\n  })\n})\n```\n\n## License\n\n[Apache-2.0](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakinoccc%2Fjsonx-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakinoccc%2Fjsonx-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakinoccc%2Fjsonx-mock/lists"}