{"id":19848353,"url":"https://github.com/ctuanle/json-serve","last_synced_at":"2026-04-13T12:01:46.973Z","repository":{"id":61411950,"uuid":"512293365","full_name":"ctuanle/json-serve","owner":"ctuanle","description":"A tool that allows you to create a testing api within less than a minute by serving a json file.","archived":false,"fork":false,"pushed_at":"2022-10-24T08:40:58.000Z","size":280,"stargazers_count":0,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-04T12:39:38.142Z","etag":null,"topics":["fake-api","json","npm-package","rest-api","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@ctuanle/json-serve","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ctuanle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-09T21:58:53.000Z","updated_at":"2022-10-28T15:39:13.000Z","dependencies_parsed_at":"2022-10-17T06:12:07.891Z","dependency_job_id":null,"html_url":"https://github.com/ctuanle/json-serve","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ctuanle/json-serve","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctuanle%2Fjson-serve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctuanle%2Fjson-serve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctuanle%2Fjson-serve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctuanle%2Fjson-serve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ctuanle","download_url":"https://codeload.github.com/ctuanle/json-serve/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctuanle%2Fjson-serve/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31751705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T09:16:15.125Z","status":"ssl_error","status_checked_at":"2026-04-13T09:16:05.023Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["fake-api","json","npm-package","rest-api","typescript"],"created_at":"2024-11-12T13:17:00.071Z","updated_at":"2026-04-13T12:01:46.949Z","avatar_url":"https://github.com/ctuanle.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## JSON-Serve\n\nLightweight, simple yet fast and useful tool that help you create a fake rest-api for your frontend by serving a json file.\n\n## Installation\n\n```shell\nyarn add @ctuanle/json-serve --dev\n```\n\nor\n\n```shell\nnpm install @ctuanle/json-serve --save-dev\n```\n\n## Demo\n\nA [simple demo](./demo) on [fly.io](https://fly.io/). Here is the base api of my demo:\n\n```shell\nhttps://jss-demo.fly.dev/\n```\n\n## Usage\n\n```shell\nyarn jss [json-path] [port] [other-options]\n```\n\n| Options     | Required |  Default  | Description                 |\n| :---------- | :------: | :-------: | :-------------------------- |\n| json-path   |    no    | data.json | Path to your json file      |\n| port        |    no    |   3000    | Port on which server run    |\n| --no-strict |    no    |   false   | Turn on no-strict mode      |\n| --readonly  |    no    |   false   | Turn on readonly mode       |\n| --persist   |    no    |   false   | Turn on save-change-to-disk |\n\n### Available methods\n\n- GET\n- POST\n- PUT\n- DELETE\n- OPTIONS\n\n### No-strict mode\n\nBy default, you can only post/put/delete to array data. But in no-strict mode, these action are allowed with object type (key-value).\n\n### Read-only mode\n\nIn this mode, only GET requests are allowed. Default is false.\n\n### Persist\n\nSave changes created by POST/PUT/DELETE to your json file. Default is false, so changes are kept only on memory and will be deleted when you turn server off.\n\n### Example\n\nYou've create a data.json file:\n\n```shell\nyarn jss data.json 3000\n```\n\nOr if you're too lazy and you don't specify a path, a prompt will appear and ask you if you want to create one with pre-defined data for you:\n\n```shell\nyarn jss\n```\n\nYou want to serve your json file and persist changes:\n\n```shell\nyarn jss data.json 3000 --persist\n```\n\n## Details\n\nIf your json file contains this content:\n\n```json\n{\n  \"method\": [\n    {\n      \"name\": \"GET\"\n    },\n    {\n      \"name\": \"POST\"\n    }\n  ],\n  \"protocol\": {\n    \"1\": \"HTTP\",\n    \"2\": \"UDP\"\n  }\n}\n```\n\nAll available routes are:\n\n```ts\n/method\n/method/[index]\n/protocol\n/protocol/[index]\n```\n\n### GET\n\nTo get \"protocol\", you can go with `GET /protocol`.\n\nOr to get all methods, go with `GET /method`.\n\nPlus, with array data, you can filter it with query, for example, to get all method that name is \"GET\", `GET /method?name=GET`\n\n### POST\n\nWith post request, you can update your json file.\n\nIf the target resources is an array, received data will be pushed into the array.\n\nEx: `POST /method` with body `{\"name\": \"PUT\"}` will turn above data into\n\n```json\n{\n  \"method\": [\n    {\n      \"name\": \"GET\"\n    },\n    {\n      \"name\": \"POST\"\n    },\n    {\n      \"name\": \"PUT\"\n    }\n  ],\n  \"protocol\": {\n    \"1\": \"HTTP\",\n    \"2\": \"UDP\"\n  }\n}\n```\n\nPlease note that if you edit json file manually while the server is running, edited data won't be seen by the server. In that case, restart the server.\n\n### PUT\n\n`PUT /protocol/0` with body `{\"name\": \"PATCH\"}` and `PUT /protocol/2` with body `\"TCP\"` will turn above data into:\n\n```json\n{\n  \"method\": [\n    {\n      \"name\": \"PATCH\"\n    },\n    {\n      \"name\": \"POST\"\n    },\n    {\n      \"name\": \"PUT\"\n    }\n  ],\n  \"protocol\": {\n    \"1\": \"HTTP\",\n    \"2\": \"TCP\"\n  }\n}\n```\n\n#### DELETE\n\nWith DELETE requests, you can delete a specific data.\n\n`DELETE /method/2` and `DELETE /protocol/2` will turn above data into:\n\n```json\n{\n  \"method\": [\n    {\n      \"name\": \"PATCH\"\n    },\n    {\n      \"name\": \"POST\"\n    },\n    null\n  ],\n  \"protocol\": {\n    \"1\": \"HTTP\",\n    \"2\": null\n  }\n}\n```\n\n## Screenshots\n\nColorful console logging:\n\n![Logging Console](./public/console.png 'Logging console')\n\nSample response:\n\n![Server response](./public/sample.png 'Sample response')\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctuanle%2Fjson-serve","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fctuanle%2Fjson-serve","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctuanle%2Fjson-serve/lists"}