{"id":24926148,"url":"https://github.com/divedylan/sardine","last_synced_at":"2025-04-09T20:07:25.958Z","repository":{"id":57110240,"uuid":"382527902","full_name":"diveDylan/sardine","owner":"diveDylan","description":"one step mock server 🔧","archived":false,"fork":false,"pushed_at":"2021-08-03T02:36:36.000Z","size":1641,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T20:07:17.193Z","etag":null,"topics":["fake","koa","mock","openapi","swagger"],"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/diveDylan.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}},"created_at":"2021-07-03T04:52:06.000Z","updated_at":"2023-03-07T07:14:06.000Z","dependencies_parsed_at":"2022-08-20T17:40:13.424Z","dependency_job_id":null,"html_url":"https://github.com/diveDylan/sardine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diveDylan%2Fsardine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diveDylan%2Fsardine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diveDylan%2Fsardine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diveDylan%2Fsardine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/diveDylan","download_url":"https://codeload.github.com/diveDylan/sardine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103872,"owners_count":21048245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["fake","koa","mock","openapi","swagger"],"created_at":"2025-02-02T12:26:04.038Z","updated_at":"2025-04-09T20:07:25.931Z","avatar_url":"https://github.com/diveDylan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cdiv style=\"text-align: center; height: 420px; position:relative; \"\u003e\n  \u003cimg src=\"./sardine.jpeg\" style=\"border-radius: 10px; filter: blur(1px)\"/\u003e\n  \u003cmain style=\"text-align: center; position: absolute; top: 80px; width: 100%; z-index: 9\"\u003e\n    \u003ch1 style=\"color: white; font-size: 80px\"\u003eSardine\u003c/h1\u003e\n  \u003c/main\u003e\n\u003c/div\u003e\n\n\u003cp style=\"text-align: center; margin-top: 10px\"\u003e\n  \u003cimg src=\"https://img.shields.io/travis/com/diveDylan/sardine\" /\u003e\n  \u003cimg src=\"https://img.shields.io/codecov/c/github/diveDylan/sardine\" /\u003e\n\u003c/p\u003e\n\n\n\n`Sardine` is one step mock tool,  via `swagger v2`, `chance`, `koa`. It will check `request` and return `response`. You can set swagger `format` property with chance method name to fake different types data~\n\n\n### Install\n\n``` bash\nnpm install sardine -D\n//or\nyarn add sardine -D\n\n```\n\n### Usage\n\n```js\n// mock.js\nconst {\n  default: Sardine,\n  chanceInstance,\n  responseBodyMiddleware // a middleware Examples\n} = require('sardine')\n\nnew Sardine({\n  url: 'https://petstore.swagger.io/v2/swagger.json',\n  port: 9000,\n})\n\n```\nRun `node mock.js` to start your first sardine mock server\n\n`Options`:\n``` typescript\ninterface SardineOptions {\n  url: string\n  port?: number\n  requestMiddlewares?: Middleware[]\n  responseMiddleWares?: Middleware[]\n}\n/* make it is possible to config your chanceInstance\n  */\npublic chanceInstance: {\n  /**\n   * config chance fake count of arrays\n   */\n  __DEFAULT_ARRAY_COUNT?: number\n  /**\n   * max stack size for nest object\n   */\n  _MAX_NEST_STACK_SIZE?: number\n} = chanceInstance\n\n```\n- `url` swagger json url\n- `port` mock sever port\n- `requestMiddlewares` \u0026 `responseMiddleWares` middleware use in koa mock server, [more about koa](https://koajs.com/)\n\n\n\n### Swagger Schemes\n\n 📖 : [Swagger Schemes V2](https://swagger.io/specification/v2/#swaggerSchemes)\n\n 💡: \u003cb\u003eNewton's 🍎\u003c/b\u003e\n\u003e However, the format property is an open string-valued property, and can have any value to support documentation needs. Formats such as \"email\", \"uuid\", etc., can be used even though they are not defined by this specification\n\n\nYou can create a lot fake data via different format type(id, card, png, city)\n\n🚥 : \u003cb\u003eRules\u003c/b\u003e\n- `number` types use `minimum` \u0026 `maximum`\n\n- `string` types use `maxLength`  \u0026 `minLength`\n\n- `array` types use `maxItems` \u0026 `minItems`\n\n- `enum` types use for `options`\n\n- `default` value use for fake value\n\n\n### TODO\n\n- swagger v3 support\n- request validtor middleware（options 😄）\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivedylan%2Fsardine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdivedylan%2Fsardine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivedylan%2Fsardine/lists"}