{"id":18557412,"url":"https://github.com/prestaul/express-json-transform","last_synced_at":"2025-08-30T18:14:30.553Z","repository":{"id":146308433,"uuid":"57808560","full_name":"Prestaul/express-json-transform","owner":"Prestaul","description":"Express middleware for intercepting and transforming json responses","archived":false,"fork":false,"pushed_at":"2016-05-01T23:16:51.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-05T11:55:19.308Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Prestaul.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":"2016-05-01T20:35:13.000Z","updated_at":"2016-05-01T23:16:52.000Z","dependencies_parsed_at":"2023-06-26T01:43:38.522Z","dependency_job_id":null,"html_url":"https://github.com/Prestaul/express-json-transform","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Prestaul/express-json-transform","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prestaul%2Fexpress-json-transform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prestaul%2Fexpress-json-transform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prestaul%2Fexpress-json-transform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prestaul%2Fexpress-json-transform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Prestaul","download_url":"https://codeload.github.com/Prestaul/express-json-transform/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Prestaul%2Fexpress-json-transform/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272885662,"owners_count":25009672,"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","status":"online","status_checked_at":"2025-08-30T02:00:09.474Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-06T21:35:32.060Z","updated_at":"2025-08-30T18:14:30.531Z","avatar_url":"https://github.com/Prestaul.png","language":"JavaScript","readme":"# express-json-transform\n\nExpress middleware for intercepting and transforming json responses.\n\n\n## Installation\n\n```bash\nnpm i -S express-json-transform\n```\n\n\n## Usage\n\nA transform is passed an object from the response and it returns a replacement.\n\n\n### Basic usage `jsonTransform( transform )`\n\nMiddleware can be created by passing a transform function. The transform function will be called with a response object prior to json serialization and it must return a replacement object.\n\n```js\nvar express = require('express'),\n\tjsonTransform = require('express-json-transform');\n\n// Create a transform to remove sensitive data from responses\nvar cleanJson = jsonTransform(function(json) {\n\tdelete json.sensitiveInfo;\n\treturn json;\n});\n\nvar app = express();\n\n// The middleware can be used anywhere express accepts middleware\napp.use(cleanJson);\n```\n\nNow when your route handlers call `res.json({ ... })` or `res.send({ ... })` the objects will be transformed before being sent to the client.\n\n### Conditional usage `jsonTransform( condition, transform )`\n\nMiddleware can optionally be created with a function that evaluates whether or not to run the transform. The condition function will be called with a request object and a response object and must return a boolean indicating whether or not the transform should run.\n\n```js\nvar express = require('express'),\n\tjsonTransform = require('express-json-transform');\n\n// Create a transform to conditionally remove sensitive data from responses\nvar cleanJson = jsonTransform(function(req, res) {\n    return !!req.params.includeUser;\n}, function(json) {\n\tdelete json.sensitiveInfo;\n\treturn json;\n});\n\nvar app = express();\n\n// The middleware can be used anywhere express accepts middleware\napp.use(cleanJson);\n```\n\n### Middleware location\n\nExpress will let you define middleware in several different places. Each of these uses is valid:\n\n```js\nvar express = require('express'),\n    Router = express.Router;\n\nvar transform = require('express-json-transform')(function(json) {\n    // modify the response...\n    return json;\n});\n\nvar app = express();\napp.use(transform) // application-level middleware\napp.get('/path', transform, handler); // middleware for specific route\napp.get('/path', [otherMiddleware, transform, handler]) // stacked with other middleware\n\nvar router = new Router();\nrouter.use(transform) // router-level middleware\nrouter.get('/path', transform, handler); // middleware for specific route\nrouter.get('/path', [otherMiddleware, transform, handler]) // stacked with other middleware\napp.use(router);\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprestaul%2Fexpress-json-transform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprestaul%2Fexpress-json-transform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprestaul%2Fexpress-json-transform/lists"}