{"id":23363325,"url":"https://github.com/neki-dev/moccu","last_synced_at":"2026-02-15T03:02:12.358Z","repository":{"id":268468050,"uuid":"904454525","full_name":"neki-dev/moccu","owner":"neki-dev","description":"📟 Simple typescript mock server with memory context","archived":false,"fork":false,"pushed_at":"2024-12-30T08:44:04.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-06T03:45:06.822Z","etag":null,"topics":["api","context","memory","mock","proxy","response","serve","server"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neki-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2024-12-16T23:25:38.000Z","updated_at":"2024-12-30T08:44:08.000Z","dependencies_parsed_at":"2024-12-17T00:45:10.880Z","dependency_job_id":"25f93a9b-5322-4b8a-815a-8e205f6e3f2a","html_url":"https://github.com/neki-dev/moccu","commit_stats":null,"previous_names":["neki-dev/moccu"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/neki-dev/moccu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Fmoccu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Fmoccu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Fmoccu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Fmoccu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neki-dev","download_url":"https://codeload.github.com/neki-dev/moccu/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Fmoccu/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29466925,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T01:01:38.065Z","status":"online","status_checked_at":"2026-02-15T02:00:07.449Z","response_time":118,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["api","context","memory","mock","proxy","response","serve","server"],"created_at":"2024-12-21T12:45:34.014Z","updated_at":"2026-02-15T03:02:12.340Z","avatar_url":"https://github.com/neki-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 📟 Moccu\n[![Npm package version](https://badgen.net/npm/v/moccu)](https://npmjs.com/package/moccu)\n\nSimple typescript mock server with memory context\n\n.\n\n* ## Install\n\n```sh\nnpm i moccu --save-dev\n```\n\n.\n\n* ## Run\n\nRun the server by command\n\n```sh\nmoccu\n```\n\n.\n\n* ## Configuration\n\nCreate and configure `moccu.config.ts` file at project root. Or it will created automatically on the first start.\n\n```ts\nimport type { Config } from 'moccu';\n\nconst config: Config = {\n  /**\n   * Server port\n   */\n  port: 3000,\n\n  /**\n   * API url prefix\n   */\n  base: '',\n\n  /**\n   * List of mocked routes\n   */\n  routes: [],\n\n  /**\n   * Logger level\n   */\n  logger: 'main',\n};\n\nexport default config;\n```\n\n.\n\n* ## Mock route\n\n#### 1. Create mocked route\n\n`./__mocks__/get-user.ts`\n```ts\nimport type { Route, Request } from 'moccu';\n\nconst route: Route = {\n  /**\n   * Request path\n   */\n  path: '/user/:userId',\n\n  /**\n   * Request method\n   */\n  method: 'get',\n\n  /**\n   * Response status\n   */\n  status: 200,\n\n  /**\n   * Response body\n   */\n  response: (req: Request) =\u003e {\n    return {\n      text: `Hello, ${req.params.userId}`,\n    };\n  },\n\n  /**\n   * Response delay\n   */\n  delay: 100,\n};\n\nexport default route;\n```\n\n#### 2. Import mocked route to global config\n\n`./moccu.config.ts`\n```ts\nimport type { Config } from 'moccu';\n\nimport getUser from './__mocks__/get-user';\n\nconst config: Config = {\n  port: 3000,\n  base: '/api',\n  routes: [\n    getUser,\n  ],\n};\n\nexport default config;\n```\n\n.\n\n* ## Context example\n\nWe can change mock responses based on the global context between requests.\n\n`./moccu.config.ts`\n```ts\nimport type { Config, Request } from 'moccu';\nimport { Context } from 'moccu';\n\ntype MockContext = {\n  name: string;\n};\n\nconst config: Config = {\n  port: 3000,\n  base: '/api',\n  routes: [\n    {\n      method: 'get',\n      path: '/greet',\n      response: () =\u003e {\n        const ctx = Context.use\u003cMockContext\u003e('testContext');\n        return {\n          message: `Hello, ${ctx.name ?? 'Noname'}!`,\n        };\n      },\n    },\n    {\n      method: 'put',\n      path: '/rename',\n      response: (req: Request) =\u003e {\n        const ctx = Context.use\u003cMockContext\u003e('testContext');\n        ctx.name = req.body.value ?? 'Unnamed';\n      },\n    },\n  ],\n};\n\nexport default config;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneki-dev%2Fmoccu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneki-dev%2Fmoccu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneki-dev%2Fmoccu/lists"}