{"id":16539498,"url":"https://github.com/al3rez/jhop","last_synced_at":"2025-03-16T19:32:03.926Z","repository":{"id":57607913,"uuid":"131390550","full_name":"al3rez/jhop","owner":"al3rez","description":" 🏎Create fake REST API in one sec.","archived":false,"fork":false,"pushed_at":"2020-04-16T15:37:17.000Z","size":15,"stargazers_count":150,"open_issues_count":2,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-12T18:49:17.885Z","etag":null,"topics":["fake","go","json","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Go","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/al3rez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-28T08:34:45.000Z","updated_at":"2024-01-04T16:22:41.000Z","dependencies_parsed_at":"2022-08-30T05:22:08.896Z","dependency_job_id":null,"html_url":"https://github.com/al3rez/jhop","commit_stats":null,"previous_names":["azbshiri/jhop","cooldrip/jhop","alirezabashyri/jhop"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/al3rez%2Fjhop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/al3rez%2Fjhop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/al3rez%2Fjhop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/al3rez%2Fjhop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/al3rez","download_url":"https://codeload.github.com/al3rez/jhop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221667364,"owners_count":16860608,"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","go","json","rest-api"],"created_at":"2024-10-11T18:49:18.252Z","updated_at":"2024-10-27T11:10:21.160Z","avatar_url":"https://github.com/al3rez.png","language":"Go","funding_links":["https://www.buymeacoffee.com/alirezabashiri"],"categories":[],"sub_categories":[],"readme":"# jhop [![codecov](https://codecov.io/gh/cooldrip/jhop/branch/master/graph/badge.svg)](https://codecov.io/gh/cooldrip/jhop) [![Build Status](https://travis-ci.org/cooldrip/jhop.svg?branch=master)](https://travis-ci.org/cooldrip/jhop)\n\n🏎Create fake REST API in one sec.\n\n\u003cp align=\"center\"\u003e\u003c/p\u003e\n\u003ca href=\"https://www.buymeacoffee.com/alirezabashiri\" target=\"_blank\"\u003e\u003cimg src=\"https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png\" alt=\"Buy Me A Coffee\" style=\"height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;\" \u003e\u003c/a\u003e\n\n## Install\n\n```\n~ $ go get github.com/cooldrip/jhop/cmd/jhop\n```\n\n## CLI Example\n\nCreate a file `recipes.json`:\n\n```json\n{\n  \"recipes\": [\n    { \"id\": 1, \"prep_time\": \"1h\", \"difficulty\": \"hard\" },\n    { \"id\": 2, \"prep_time\": \"15m\", \"difficulty\": \"easy\" }\n  ]\n}\n```\n\nPassing the JSON file to `jhop`:\n\n```\n~ $ jhop recipes.json\n```\n\nNow you can go to `localhost:6000/recipes` and get the collection:\n\n```json\n{\n  \"recipes\": [\n    { \"id\": 1, \"prep_time\": \"1h\", \"difficulty\": \"hard\" },\n    { \"id\": 2, \"prep_time\": \"15m\", \"difficulty\": \"easy\" }\n  ]\n}\n```\n\nor you can just get a single recipe `localhost:6000/recipes/1`:\n\n```json\n{ \"id\": 1, \"prep_time\": \"1h\", \"difficulty\": \"hard\" }\n```\n\n## API example\n\n```go\n  f, err := os.Open(\"recipes.json\")\n  if err != nil {\n    log.Fatalf(\"file opening failed: %s\", err)\n  }\n  h, err := jhop.NewHandler(f)\n  if err != nil {\n    log.Fatalf(\"handler initialization failed: %s\", err)\n  }\n\n  s := httptest.NewServer(h)\n  defer s.Close()\n\n  resp, err := http.Get(fmt.Sprintf(\"%s/recipes/1\", s.URL))\n  if err != nil {\n    log.Fatalf(\"request to test server failed: %s\", err)\n  }\n\n  io.Copy(os.Stdout, resp.Body) // {\"difficulty\":\"hard\",\"id\":1,\"prep_time\":\"1h\"}\n```\n\n## CLI usage\n\n```\nNAME:\n   jhop - Create fake REST API in one sec.\n\nUSAGE:\n   jhop [global options] command [command options] [arguments...]\n\nVERSION:\n   0.0.0\n\nCOMMANDS:\n     help, h  Shows a list of commands or help for one command\n\nGLOBAL OPTIONS:\n   --port value   Set port (default: \"6000\")\n   --host value   Set host (default: \"localhost\")\n   --help, -h     show help\n   --version, -v  print the version\n```\n\n## TODO\n\n* [x] Single resource\n* [ ] Custom routes\n* [ ] Middleware\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fal3rez%2Fjhop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fal3rez%2Fjhop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fal3rez%2Fjhop/lists"}