{"id":17531525,"url":"https://github.com/dab0mb/requestor","last_synced_at":"2025-07-25T13:03:52.182Z","repository":{"id":66209470,"uuid":"44205145","full_name":"DAB0mB/requestor","owner":"DAB0mB","description":"declerative request entities","archived":false,"fork":false,"pushed_at":"2015-10-19T22:20:41.000Z","size":180,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-06T21:13:44.367Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/DAB0mB.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":"2015-10-13T21:12:08.000Z","updated_at":"2015-10-15T18:14:52.000Z","dependencies_parsed_at":"2023-02-20T00:15:42.893Z","dependency_job_id":null,"html_url":"https://github.com/DAB0mB/requestor","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/DAB0mB%2Frequestor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAB0mB%2Frequestor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAB0mB%2Frequestor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAB0mB%2Frequestor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DAB0mB","download_url":"https://codeload.github.com/DAB0mB/requestor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241533630,"owners_count":19977826,"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":[],"created_at":"2024-10-20T17:25:28.695Z","updated_at":"2025-03-02T16:13:45.172Z","avatar_url":"https://github.com/DAB0mB.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Requestor\nRequests have never been more convenient and declerative. The `Requestor` library lets you define request data-stractures like [ModelRequestor](#ModelRequestor) and [CollectionRequestor](#CollectionRequestor) which can be used anywhere, anytime, on different documents. Not only that, the `Requestor` will also chain the requests using es6's `Promise`.\n\n`Requestor` is available for both server-side and client side and can be downloaded via [Github](https://github.com/DAB0mB/requestor).\n\n## Dependencies\n`Requestor` has the following dependencies on client side:\n- Promise - Which won't work on old browsers and can be loaded using any polyfilling library.\n- jquery - Which is used to make ajax requests. A costume request method can be defined using [defineRequestMethod](#defineRequestMethod).\n\n## Example\n```js\nvar Post = ModelRequestor(\"Post\", {\n  urlRoot: \"http://www.mail.com\",\n  entity: \"posts\",\n\n  requests: {\n    markAsRead: \"PUT ./markAsRead\",\n    isReaden:   \"PUT ./isReaden  \"\n  },\n\n  createMarkAsReadRequestData: function(data) {\n    return { markAsRead: data };\n  },\n\n  transformIsReadenResponseBody: function(body) {\n    return body.isReaden;\n  }\n});\n\nvar post = new Post();\n\npost.create({ username: \"DAB0mB\" }).then(function() {\n  return post.markAsRead(true);\n}).then(function() {\n  return post.isReaden();\n}).then(function(isReaden) {\n  console.log(isReaden);\n});\n```\n\n## API\n\n### Requestor\n\n#### defineRequestMethod(fn)\nDefines a custome request method\n\n#### Model(name, proto)\nCreates a model requestor which is responsible for making requests related to a single document.\nReturns a class which inherits from [ModelRequestor](#ModelRequestor).\n\n#### Collection(name, proto)\nCreates a collection requestor which is responsible for making requests related to multi documents or a collection of documents.\nReturns a class which inherits from [CollectionRequestor](#CollectionRequestor).\n\n### ModelRequestor\n\n### CollectionRequestor\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdab0mb%2Frequestor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdab0mb%2Frequestor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdab0mb%2Frequestor/lists"}