{"id":20629867,"url":"https://github.com/conorturner/urest","last_synced_at":"2026-04-17T23:03:28.254Z","repository":{"id":44217832,"uuid":"134721771","full_name":"conorturner/urest","owner":"conorturner","description":"Zero dependency rest framework for Node.js","archived":false,"fork":false,"pushed_at":"2022-12-07T19:59:58.000Z","size":220,"stargazers_count":3,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-17T07:07:03.002Z","etag":null,"topics":["javascript-framework","nodejs","rest","rest-api"],"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/conorturner.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}},"created_at":"2018-05-24T13:48:17.000Z","updated_at":"2023-10-12T12:34:36.000Z","dependencies_parsed_at":"2023-01-24T22:00:22.701Z","dependency_job_id":null,"html_url":"https://github.com/conorturner/urest","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/conorturner%2Furest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conorturner%2Furest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conorturner%2Furest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conorturner%2Furest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/conorturner","download_url":"https://codeload.github.com/conorturner/urest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242583167,"owners_count":20153395,"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":["javascript-framework","nodejs","rest","rest-api"],"created_at":"2024-11-16T14:06:17.295Z","updated_at":"2026-04-17T23:03:23.200Z","avatar_url":"https://github.com/conorturner.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![logo](https://storage.googleapis.com/public-stuff/urest-logo-2.png)\n\n\u003ch4 align=\"center\"\u003eLightweight, fast, zero dependency restful routing framework inspired by express and restify.\u003c/h3\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://www.npmjs.com/package/urest\"\u003e\u003cimg src=\"https://img.shields.io/npm/dt/urest.svg?style=for-the-badge\"\u003e\u003c/a\u003e\n\u003ca href=\"https://travis-ci.org/conorturner/urest\"\u003e\u003cimg src=\"https://img.shields.io/travis/conorturner/urest.svg?style=for-the-badge\"\u003e\u003c/a\u003e\n\u003ca href=\"https://coveralls.io/github/conorturner/urest\"\u003e\u003cimg src=\"https://img.shields.io/coveralls/github/conorturner/urest.svg?style=for-the-badge\"\u003e\u003c/a\u003e\n\u003ca href=\"/#\"\u003e\u003cimg src=\"https://img.shields.io/github/license/conorturner/urest.svg?style=for-the-badge\"\u003e\u003c/a\u003e\n\u003ca href=\"/#\"\u003e\u003cimg src=\"https://img.shields.io/bundlephobia/min/urest.svg?style=for-the-badge\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\n## Install\n```bash\n$ npm install urest\n```\n\n### Basic App\n```javascript\nconst { Rest, JsonBodyParser } = require(\"urest\");\nconst app = new Rest();\n\napp.pre(JsonBodyParser.middleware());\napp.get('/', (req, res) =\u003e res.send({message: 'Hello World'}));\napp.post(\"/echo\", (req, res) =\u003e res.send(req.body));\n```\n#### Native HTTP server\n```javascript\napp.native().listen(8000);\n```\n#### AWS Lambda\n```javascript\nexports.handle = (e, context) =\u003e app.lambda(e, context);\n```\n#### Google Cloud Functions\n```javascript\nmodule.exports = app.gcf();\n```\n\n## UErrors\nErrors passed into the next function will be logged, then returned to the client obscured behind a unique ID.\n```javascript\nconst { UErrors } = require(\"urest\");\nconst { UInternalServerError } = UErrors;\n\napp.get(\"/broken\", (req, res, next) =\u003e next(new UInternalServerError(\"This is logged\")));\n\n```\n#### Response\n```json\n// 500\n{\n    \"code\":\"InternalServer\",\n    \"eid\":\"3ccf6fadf79875f58631a8c7ecc302523b563423\"\n}\n```\n#### Log\n```json\n{\n    \"level\":500,\n    \"request_id\":\"1a376e5eb266511a35aefcc7ffad7d50aef5df40\",\n    \"environment\":\"develop\",\n    \"service\": \"my-service\",\n    \"stack\":\"UInternalServerError: This is logged\\n    at Object.UError (urest/library/UErrors.js:7:8)\\n    at new \u003canonymous\u003e (urest/library/UErrors.js:11:9)\\n    at runHandler (urest/library/Rest.js:79:22)\\n    at next (urest/library/Rest.js:87:4)\\n    at IncomingMessage.req.on.on (urest/library/JsonBodyParser.js:26:6)\\n    at emitNone (events.js:106:13)\\n    at IncomingMessage.emit (events.js:208:7)\\n    at endReadableNT (_stream_readable.js:1056:12)\\n    at _combinedTickCallback (internal/process/next_tick.js:138:11)\\n    at process._tickCallback (internal/process/next_tick.js:180:9)\",\n    \"message\":\"This is logged\",\n    \"eid\":\"3ccf6fadf79875f58631a8c7ecc302523b563423\",\n    \"code\":\"InternalServer\",\n    \"statusCode\":500\n}\n```\n\n## Interceptors\nInterceptors works in much the same way as middleware but act on the response before it is returned to the client.\n\n#### GZIP Interceptor\n\nThe following example will check for the header `\"accept-encoding\": \"gzip\"` and will compress response bodies as fit.\n\n```javascript\nconst { Rest, JsonBodyParser } = require(\"urest\");\nconst { Neutron } = require(\"urequest\");\nconst app = new Rest();\n\napp.int(Neutron.intercept());\n\napp.pre(JsonBodyParser.middleware());\napp.post(\"/echo\", (req, res) =\u003e res.send(req.body));\nconst server = app.native().listen(1234);\n```\n\n#### Custom Interceptors\n\nThe value passed into res.send is attached as `res.responseData`, the following example checks for a property in the response and prevents the request if not true.\n\n```javascript\nconst { Rest, UErrors } = require(\"urest\");\nconst { UUnauthorizedError } = UErrors;\n\nconst app = new Rest();\napp.int((req, res, next) =\u003e {\n   if (res.responseData.authed !== true) next(new UUnauthorizedError());\n   else next();\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconorturner%2Furest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconorturner%2Furest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconorturner%2Furest/lists"}