{"id":20833651,"url":"https://github.com/droideveloper/restfuljsonwrap","last_synced_at":"2025-08-19T11:10:14.320Z","repository":{"id":57355018,"uuid":"80371014","full_name":"droideveloper/RESTfulJSONWrap","owner":"droideveloper","description":"RESTful Express Json Response Wrap","archived":false,"fork":false,"pushed_at":"2017-01-29T20:44:38.000Z","size":3,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T08:45:25.189Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/droideveloper.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":"2017-01-29T20:37:28.000Z","updated_at":"2017-10-16T20:57:03.000Z","dependencies_parsed_at":"2022-09-05T03:21:15.923Z","dependency_job_id":null,"html_url":"https://github.com/droideveloper/RESTfulJSONWrap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/droideveloper/RESTfulJSONWrap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/droideveloper%2FRESTfulJSONWrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/droideveloper%2FRESTfulJSONWrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/droideveloper%2FRESTfulJSONWrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/droideveloper%2FRESTfulJSONWrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/droideveloper","download_url":"https://codeload.github.com/droideveloper/RESTfulJSONWrap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/droideveloper%2FRESTfulJSONWrap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266042002,"owners_count":23867960,"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-11-18T00:16:17.532Z","updated_at":"2025-07-19T23:36:08.471Z","avatar_url":"https://github.com/droideveloper.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## RESTful Express Response Wrap-JSON\n\nWraps JSON with as follows;\n\n`Array\u003cT\u003e or []`:\n```json\n{\n  \"code\": 200,\n  \"message\": \"success\",\n  \"href\": \"$current\",\n  \"offset\": 0,\n  \"limit\": 25,\n  \"count\": 0,\n  \"data\": []\n}\n```\n\n`T or {}` :\n```json \n{\n  \"code\": 200,\n  \"message\": \"success\",\n  \"href\": \"$current\",\n  \"data\": {}\n}\n```\n\n### How to install\n\nusing npm;\n\n`npm install --save restful-express-response-wrap`\n\n### How to use\n\nin server.js;\n\n```javascript\nvar express = require(\"express\");\nvar wrap = require(\"restful-express-response-wrap\");\n\nvar server = express();\n\nserver.get(\"/\", function(req, res, next) {\n  var success = ...;\n  if(success) {\n    // use array or object as res.data param\n    res.data = [ { name: \"node\", lang: \"javascript\" } ] || { name: \"node\", lang: \"javascript\" };\n  } else {\n    res.error = { status: 401, message: \"Unauthroized\", name: \"Unauthroized\" };\n  }\n  next(); // call to wrap\n});\n\n// for offset and limit to be used in Array response.\n// { offset: 0, limit: 10 } this part is optional default is 0, 25 as respectively\nserver.use(wrap());\n// also wrap register for 404 and 500 errors\n// always returns json but server status code served inside json with message.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdroideveloper%2Frestfuljsonwrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdroideveloper%2Frestfuljsonwrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdroideveloper%2Frestfuljsonwrap/lists"}