{"id":18746883,"url":"https://github.com/iainjreid/drowsy","last_synced_at":"2025-07-18T18:36:21.813Z","repository":{"id":47691961,"uuid":"72483022","full_name":"iainjreid/drowsy","owner":"iainjreid","description":"😪 Lazy integrations tool for RESTful interfaces to aid POC development and streamline integrations","archived":false,"fork":false,"pushed_at":"2021-08-17T21:03:42.000Z","size":1104,"stargazers_count":19,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-09T05:34:48.676Z","etag":null,"topics":["api","api-client","api-restful","api-server","browser","javascript","nodejs","rest","rest-client","rest-server"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/iainjreid.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":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2016-10-31T22:24:03.000Z","updated_at":"2024-08-07T20:21:43.000Z","dependencies_parsed_at":"2022-08-20T17:10:12.966Z","dependency_job_id":null,"html_url":"https://github.com/iainjreid/drowsy","commit_stats":null,"previous_names":["chaffity/drowsy","emphori/drowsy"],"tags_count":36,"template":false,"template_full_name":null,"purl":"pkg:github/iainjreid/drowsy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iainjreid%2Fdrowsy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iainjreid%2Fdrowsy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iainjreid%2Fdrowsy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iainjreid%2Fdrowsy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iainjreid","download_url":"https://codeload.github.com/iainjreid/drowsy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iainjreid%2Fdrowsy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265810378,"owners_count":23831950,"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":["api","api-client","api-restful","api-server","browser","javascript","nodejs","rest","rest-client","rest-server"],"created_at":"2024-11-07T16:27:20.270Z","updated_at":"2025-07-18T18:36:21.793Z","avatar_url":"https://github.com/iainjreid.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Drowsy\n\nA universal REST client that makes integrating with services so wonderfully\nsimple, you'll probably forget you're talking to an API after all. Think gRPC\nor SOAP, but for REST.\n\n## Description\n\nA hugely versatile REST client and server interface, that lets you extend\nlibraries like Request, Express, Axios, Fastify, and many more, largely by\nremoving the need for the boilerplate code often inherent when using these\ntools.\n\nAt its heart, Drowsy builds upon a common design pattern found in the majority\nof the HTTP related tools that the community has to offer. More often than not,\nthe pattern looks like this.\n\n```javascript\nlibrary.get(url[, options][, cb])\n```\n\n\u003e This was likely inspired by the original Node.js HTTP module\n\nDrowsy is able to simplify the above by hoisting both the method and URL into\nthe function name, providing a more gRPCesque interface, and cutting out any\nhardcoded URL strings.\n\n```javascript\nAPI.getPing([, cb]);\n```\n\nThis is an incredibly powerful abstraction, and one that can be stacked\nendlessly. This easily leads to even further optimisations, allowing your REST\nclient or server to be treated as though it was nothing more than a large object\nof functions.\n\n```javascript\nvar UsersAPI = API.users\n\n// Call GET hostname/users/all\nUsersAPI.getAll([, cb])\n\n// Call POST hostname/users/\u003cuserId\u003e\nUsersAPI.post[userId](options[, cb])\n```\n\nThese function calls are largely identical for the client and server, only when\nthere are placeholders in the URL will the Drowsy syntax differ.\n\n\u003e Featured on [Changelog][1.1]\n\n[1.1]: https://changelog.com/news/drowsy-the-laziest-rest-client-youll-ever-see-wwn0\n\n## Examples\n\nBelow is a super simple example demonstrating how easy it can be to retrieve the\nfirst page of public Gists currently available on GitHub.\n\n```javascript\nconst github = drowsy(request, \"https://api.github.com/\");\n\ngithub.getGists({\n  headers: {\n    \"User-Agent\": \"Octo-app\"\n  }\n});\n```\n\nBy calling the method `getGists` you're in fact performing a GET request to the\nendpoint \"/gists\" through the handler provided (in this case, Request). The\nhandler returns a Promise that will, hopefully, resolve in a timely fashion with\nthe first page of public Gists found on GitHub.\n\n## Usage\n\n### Single command\n\nThe single command approach is the simplest and most human readable of the\nbunch, it has some minor limitations, but nothing that can't be avoided with a\nlittle imagination.\n\nEach request is composed using just one lookup _(both the HTTP method and the\nURL must be known at the time of writing)_. It's super elegant, and recommended\nto be used when talking to an API that has collections, or otherwise grouped\nendpoints exposed.\n\n#### Limitations\n\nThis approach will only work with single word URL parts, and requires that you\nknow _all_ of them too, here's a breakdown of what would and wouldn't work.\n\n```javascript\n// Yes - API.getCitiesLondon()\n/cities/london\n\n// Yes - API.getCitiesLondonPopulation()\n/cities/london/population\n\n// No - try API.getCities[cityId]()\n/cities/[:cityId]\n\n// No - try API.getCitiesLondon[\"is-capital\"]()\n/cities/london/is-capital\n```\n\n## License\n\nThis project is released under the [MIT License][4.1]. Enjoy responsibly ✌️\n\n[4.1]: ./LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiainjreid%2Fdrowsy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiainjreid%2Fdrowsy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiainjreid%2Fdrowsy/lists"}