{"id":17436233,"url":"https://github.com/rtritto/uws-wrapper","last_synced_at":"2025-03-01T08:32:47.796Z","repository":{"id":257824044,"uuid":"871234044","full_name":"rtritto/uws-wrapper","owner":"rtritto","description":"Archived: Wrapper for uWebSockets.js","archived":true,"fork":false,"pushed_at":"2024-10-15T12:18:54.000Z","size":666,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-20T20:37:52.884Z","etag":null,"topics":["http","http-server","nodejs","plugin","proxy-protocol","typescript","uwebsocketsjs","uws","websockets","wrapper"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/rtritto.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-11T14:31:57.000Z","updated_at":"2024-10-15T12:19:11.000Z","dependencies_parsed_at":"2024-10-19T08:54:19.630Z","dependency_job_id":null,"html_url":"https://github.com/rtritto/uws-wrapper","commit_stats":null,"previous_names":["rtritto/uws-wrapper"],"tags_count":18,"template":false,"template_full_name":"rtritto/template-yarn-berry","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtritto%2Fuws-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtritto%2Fuws-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtritto%2Fuws-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtritto%2Fuws-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rtritto","download_url":"https://codeload.github.com/rtritto/uws-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241341381,"owners_count":19947097,"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":["http","http-server","nodejs","plugin","proxy-protocol","typescript","uwebsocketsjs","uws","websockets","wrapper"],"created_at":"2024-10-17T10:07:14.966Z","updated_at":"2025-03-01T08:32:47.718Z","avatar_url":"https://github.com/rtritto.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ARCHIVED\nUse [uws-utils](https://github.com/rtritto/uws-common) instead\n\n# uws-wrapper\n\nPlugin for [uWebSockets.js](https://github.com/uNetworking/uWebSockets.js) that wraps _App_ instance to improve DX (Developer Experience).\n\n## Installation\n```sh\nyarn add uws-wrapper\n```\n\n## Changes/Features:\n- Replace the parameters in the callback of the http request functions with a context object:\n\n  ```diff\n  -app[\u003cHTTP_METHOD\u003e](\u003cROUTE_PATTERN\u003e, (res, req) =\u003e { ... })\n  +app[\u003cHTTP_METHOD\u003e](\u003cROUTE_PATTERN\u003e, ({ req, res }) =\u003e { ... })\n  ```\n- Replace the result of `res.getQuery()` method with a query object (generated by [fastest-qs](https://github.com/rtritto/fastest-qs)):\n\n  ```diff\n  const query = req.getQuery()\n  -console.log('Query:', query)   // q=1\u0026q2\n  +console.log('Query:', query)   // { q: 1, q: 2 }\n  ```\n- Add `req.body.json` method\n\n  ```ts\n  const jsonBody = await req.body.json()\n  console.log(jsonBody)   // { prop1: 1, prop2: 2 }\n  ```\n\n## Register the Plugin / Usage\n```ts\nimport { App } from 'uWebSockets.js'\nimport { transformCallback } from 'uws-wrapper'\n\nconst port = +(process.env.PORT || 3000)\n\n// Register the Plugin\nconst app = transformCallback({\n  // Default HTTP methods: 'get', 'post', 'options', 'del', 'patch', 'put', 'head', 'connect', 'trace', 'any'\n  httpMethods: new Set(['get', 'post'])\n})(App())\n\n// Usage\napp\n  .get(pattern, async ({ req, res }) =\u003e {\n    console.log('Query:', req.getQuery())   // { q: 1, q: 2 }\n    console.log('JSON body:', await req.body.json())  // { prop1: 1, prop2: 2 }\n    res.end('Hello World!')\n  })\n  .listen(port, (listenSocket) =\u003e {\n    if (listenSocket) {\n      console.log(`Server running at http://localhost:${port}`)\n    } else {\n      console.log(`Failed to listen to port ${port}`)\n    }\n  })\n```\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtritto%2Fuws-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frtritto%2Fuws-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtritto%2Fuws-wrapper/lists"}