{"id":13436416,"url":"https://github.com/serayuzgur/weld","last_synced_at":"2025-04-04T09:08:35.560Z","repository":{"id":38896640,"uuid":"86782228","full_name":"serayuzgur/weld","owner":"serayuzgur","description":"Full fake REST API generator written with Rust","archived":false,"fork":false,"pushed_at":"2023-12-07T14:52:05.000Z","size":141,"stargazers_count":310,"open_issues_count":4,"forks_count":25,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-28T08:07:12.430Z","etag":null,"topics":["hyper","json","json-api","mock","mock-server","rust","rust-lang","rust-language","rustlang","serde","weld"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/serayuzgur.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":"FUNDING.yml","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},"funding":{"patreon":"serayuzgur","github":"serayuzgur"}},"created_at":"2017-03-31T05:43:05.000Z","updated_at":"2025-03-26T06:07:38.000Z","dependencies_parsed_at":"2023-12-27T00:22:38.240Z","dependency_job_id":"471a83f1-6796-458d-a28e-895e9bca0446","html_url":"https://github.com/serayuzgur/weld","commit_stats":{"total_commits":96,"total_committers":4,"mean_commits":24.0,"dds":0.05208333333333337,"last_synced_commit":"70e5f10da5dbb66bdba0684a7a38c7152b2c5788"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serayuzgur%2Fweld","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serayuzgur%2Fweld/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serayuzgur%2Fweld/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serayuzgur%2Fweld/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serayuzgur","download_url":"https://codeload.github.com/serayuzgur/weld/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247149501,"owners_count":20891954,"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":["hyper","json","json-api","mock","mock-server","rust","rust-lang","rust-language","rustlang","serde","weld"],"created_at":"2024-07-31T03:00:47.918Z","updated_at":"2025-04-04T09:08:35.537Z","avatar_url":"https://github.com/serayuzgur.png","language":"Rust","funding_links":["https://patreon.com/serayuzgur","https://github.com/sponsors/serayuzgur"],"categories":["Applications","应用程序 Applications","应用","应用 Applications"],"sub_categories":["贡献"],"readme":"# Weld\nFull fake REST API generator.\n\n[![weldmock' current version badge](https://img.shields.io/crates/v/weldmock.svg)](https://crates.io/crates/weldmock)\n[![Build Status](https://travis-ci.org/serayuzgur/weld.svg?branch=master)](https://travis-ci.org/serayuzgur/weld)\n[![codecov](https://codecov.io/gh/serayuzgur/weld/branch/master/graph/badge.svg)](https://codecov.io/gh/serayuzgur/weld)\n\n\nThis project is heavily inspired by [json-server](https://github.com/typicode/json-server), written with rust. \n\n## Synopsis\nOur first aim is to generate a fake api from the given data source (JSON). \nIt may have bugs, missing features but if you contribute they all will be fixed.\n\n## Version [CHANGELOG](./CHANGELOG.md)\n\n## Techs\n* [**Serde**](https://github.com/serde-rs/serde) for json parsing.\n* [**Hyper**](https://github.com/hyperium/hyper) for serving.\n* [**slog**](https://github.com/slog-rs/slog) for logging.\n\n\n## Installation\n 1. Download and install **Rust** from [here](https://www.rust-lang.org/en-US/downloads.html)\n 2. Download and install **Cargo** from [here](http://doc.crates.io/)\n 3. Clone and run the project.\n\n```bash \ngit clone https://github.com/serayuzgur/weld.git\ncd weld\ncargo run\n```\n\n## Usage\n\n### Running\nExecutable can take configuration path otherwise it will use default `./weld.json`. If we take project folder as root, commands should look like one of these. If you you use `cargo build --release` version change `debug` with `release`.\n\n```bash \n./target/debug/weld  \n./target/debug/weld weld.json\n./target/debug/weld \u003cpath_to_config\u003e.json\n\n./target/release/weld  \n./target/release/weld weld.json\n./target/release/weld \u003cpath_to_config\u003e.json\n```\n\n### Configuration\nConfiguration file is a very simple json file which is responsible to hold server and database properties.\n\n```json\n{\n    \"server\": {\n        \"host\": \"127.0.0.1\",\n        \"port\": 8080\n    },\n    \"database\": {\n        \"path\": \"db.json\"\n    }\n}\n```\n\n### Database\nDatabase is a simple json file.\n\n```json\n{\n    \"owner\": {\n        \"name\": \"seray\",\n        \"surname\": \"uzgur\"\n    },\n    \"posts\": [\n        {\n            \"author\": {\n                \"name\": \"seray\",\n                \"surname\": \"uzgur\"\n            },\n            \"body\": \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.\",\n            \"id\": 1,\n            \"tags\": [\n                {\n                    \"id\": 1,\n                    \"name\": \"tech\"\n                },\n                {\n                    \"id\": 2,\n                    \"name\": \"web\"\n                }\n            ],\n            \"title\": \"Rust Rocks!\"\n        },\n        {\n            \"author\": {\n                \"name\": \"kamil\",\n                \"surname\": \"bukum\"\n            },\n            \"body\": \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.\",\n            \"id\": 2,\n            \"tags\": [\n                {\n                    \"id\": 1,\n                    \"name\": \"tech\"\n                },\n                {\n                    \"id\": 2,\n                    \"name\": \"web\"\n                }\n            ],\n            \"title\": \"TypeScript is Awesome\"\n        }\n    ],\n    \"version\": \"10.1.1\"\n}\n```\n\nHere the `owner` and `posts` are tables. They can be empty arrays/objects but they must exist as is.\n\n**NOTE :** `id`: Column is a must, all parsing uses it.\n\n### API \nApi usage is pretty simple. For now it does not support filters one other query params. Here is the list of the calls you can make with examples.\n\n* Get List \\\u003chost\\\u003e:\\\u003cport\\\u003e/\\\u003ctable\\\u003e GET\n* Get Record \\\u003chost\\\u003e:\\\u003cport\\\u003e/\\\u003ctable\\\u003e/\\\u003cid\\\u003e GET\n* Insert Record \\\u003chost\\\u003e:\\\u003cport\\\u003e/\\\u003ctable\\\u003e POST\n* Update Record \\\u003chost\\\u003e:\\\u003cport\\\u003e/\\\u003ctable\\\u003e/\\\u003cid\\\u003e PUT\n* Delete Record \\\u003chost\\\u003e:\\\u003cport\\\u003e/\\\u003ctable\\\u003e/\\\u003cid\\\u003e DELETE\n* Get Nested \\\u003chost\\\u003e:\\\u003cport\\\u003e/\\\u003ctable\\\u003e/\\\u003cid\\\u003e\u003cfield\\\u003e/\\\u003cid\\\u003e... GET\n\n#### Get List\n```json\nurl: http://127.0.0.1:8080/posts \nmethod: GET\nbody: empty\n\nresponse: \n[\n  {\n    \"author\": \"serayuzgur\",\n    \"body\": \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.\",\n    \"id\": 1,\n    \"title\": \"Rust Rocks!\"\n  },\n  {\n    \"author\": \"kamilbukum\",\n    \"body\": \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.\",\n    \"id\": 2,\n    \"title\": \"TypeScript is Awesome\"\n  }\n]\n```\n#### Get Record\n```json\nurl: http://127.0.0.1:8080/posts/1 \nmethod: GET\nbody: empty\n\nresponse: \n{\n    \"author\": {\n        \"name\": \"seray\",\n        \"surname\": \"uzgur\"\n    },\n    \"body\": \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.\",\n    \"id\": 1,\n    \"tags\": [\n        {\n            \"id\": 1,\n            \"name\": \"tech\"\n        },\n        {\n            \"id\": 2,\n            \"name\": \"web\"\n        }\n    ],\n    \"title\": \"Rust Rocks!\"\n}\n```\n#### Insert Record\n```json\nurl: http://127.0.0.1:8080/posts\nmethod: POST\nbody:\n{\n  \"author\": {\n    \"name\": \"hasan\",\n    \"surname\": \"mumin\"\n  },\n  \"body\": \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.\",\n  \"id\": 3,\n  \"tags\": [\n    {\n      \"id\": 1,\n      \"name\": \"tech\"\n    },\n    {\n      \"id\": 2,\n      \"name\": \"web\"\n    }\n  ],\n  \"title\": \"KendoUI Rocks!\"\n}\n\nresponse: \n{\n  \"author\": {\n    \"name\": \"hasan\",\n    \"surname\": \"mumin\"\n  },\n  \"body\": \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.\",\n  \"id\": 3,\n  \"tags\": [\n    {\n      \"id\": 1,\n      \"name\": \"tech\"\n    },\n    {\n      \"id\": 2,\n      \"name\": \"web\"\n    }\n  ],\n  \"title\": \"KendoUI Rocks!\"\n}\n```\n#### Update Record\n```json\nurl: http://127.0.0.1:8080/posts/3\nmethod: PUT\nbody:\n{\n  \"author\": {\n    \"name\": \"hasan\",\n    \"surname\": \"mumin\"\n  },\n  \"body\": \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.\",\n  \"id\": 3,\n  \"tags\": [\n    {\n      \"id\": 1,\n      \"name\": \"tech\"\n    },\n    {\n      \"id\": 2,\n      \"name\": \"web\"\n    }\n  ],\n  \"title\": \"KendoUI Rocks!\"\n}\n\nresponse: \n{\n  \"author\": {\n    \"name\": \"hasan\",\n    \"surname\": \"mumin\"\n  },\n  \"body\": \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.\",\n  \"id\": 3,\n  \"tags\": [\n    {\n      \"id\": 1,\n      \"name\": \"tech\"\n    },\n    {\n      \"id\": 2,\n      \"name\": \"web\"\n    }\n  ],\n  \"title\": \"Angular Rocks!\"\n}\n```\n\n#### Delete Record\n```json\nurl: http://127.0.0.1:8080/posts/3\nmethod: DELETE\nbody: empty\n\nresponse: \n{\n  \"author\": {\n    \"name\": \"hasan\",\n    \"surname\": \"mumin\"\n  },\n  \"body\": \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.\",\n  \"id\": 3,\n  \"tags\": [\n    {\n      \"id\": 1,\n      \"name\": \"tech\"\n    },\n    {\n      \"id\": 2,\n      \"name\": \"web\"\n    }\n  ],\n  \"title\": \"KendoUI Rocks!\"\n}\n```\n#### Get Nested\n```json\nurl: http://127.0.0.1:8080/posts/1/author\nmethod: GET\nbody: empty\n\nresponse:\n{\n    \"name\": \"seray\",\n    \"surname\": \"uzgur\"\n}\n```\n```json\nurl: http://127.0.0.1:8080/posts/1/author/name\nmethod: GET\nbody: empty\n\nresponse:\n\"seray\"\n```\n```json\nurl: http://127.0.0.1:8080/posts/1/tags/1\nmethod: GET\nbody: empty\n\nresponse:\n{\n    \"id\": 1,\n    \"name\": \"tech\"\n}\n```\n\n#### Query API\n##### Field selection\nGive the API consumer the ability to choose returned fields. This will also reduce the network traffic and speed up the usage of the API.\n\n```\nGET /cars?fields=manufacturer,model,id,color\n```\n\n##### Paging\n\n```\nGET /cars?_offset=10\u0026_limit=5\n```\n* Add  _offset and _limit (an X-Total-Count header is included in the response).\n\n* To send the total entries back to the user use the custom HTTP header: X-Total-Count.\n\n* Content-Range offset – limit / count.\n\n\t* offset: Index of the first element returned by the request.\n\n\t* limit: Index of the last element returned by the request.\n\n\t* count: Total number of elements in the collection.\n\n* Accept-Range resource max.\n\n* resource: The type of pagination. Must remind of the resource in use, e.g: client, order, restaurant, …\n\n* max \t  : Maximum number of elements that can be returned in a single request.\n\n##### Sorting\n\n* Allow ascending and descending sorting over multiple fields.\n* Use sort with underscore as `_sort`.\n* In code, descending describe as ` - `, ascending describe as ` + `.\n\n```GET /cars?_sort=-manufactorer,+model```\n\n##### Operators\n* Add `_filter` query parameter and continue with field names,operations and values separated by `,`.\n* Pattern `_filter=\u003cfieldname\u003e\u003coperation\u003e\u003cvalue\u003e`.\n* Supported operations.\n\t* `=` equal\n\t* `!=` not equal\n\t* `\u003c` less\n\t* `\u003c=` less or equals\n\t* `\u003e` greater\n\t* `\u003e=` greater or equals\n\t* `~=` like\n\t* `|=` in (values must be separated with `|`\n\t\n```GET http://127.0.0.1:8080/robe/users?_filter=name=seray,active=true```\n\n##### Full-text search\n\n* Add `_q`.\n\n```GET /cars?_q=nissan```\n\n## License\n\nThe MIT License (MIT) Copyright (c) 2017 Seray Uzgur\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserayuzgur%2Fweld","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserayuzgur%2Fweld","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserayuzgur%2Fweld/lists"}