{"id":24964022,"url":"https://github.com/scoutforpets/jsonapi-mapper","last_synced_at":"2026-01-12T02:20:53.422Z","repository":{"id":57140320,"uuid":"44039363","full_name":"scoutforpets/jsonapi-mapper","owner":"scoutforpets","description":"JSON API-Compliant Serialization for your Node ORM","archived":false,"fork":false,"pushed_at":"2020-03-12T18:21:55.000Z","size":266,"stargazers_count":41,"open_issues_count":10,"forks_count":24,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-10-16T10:39:09.371Z","etag":null,"topics":["bookshelf","json-api","orm","serializer"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scoutforpets.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-11T04:38:27.000Z","updated_at":"2024-12-14T15:34:26.000Z","dependencies_parsed_at":"2022-09-05T00:21:26.657Z","dependency_job_id":null,"html_url":"https://github.com/scoutforpets/jsonapi-mapper","commit_stats":null,"previous_names":["jamesdixon/oh-my-jsonapi"],"tags_count":38,"template":false,"template_full_name":null,"purl":"pkg:github/scoutforpets/jsonapi-mapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scoutforpets%2Fjsonapi-mapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scoutforpets%2Fjsonapi-mapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scoutforpets%2Fjsonapi-mapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scoutforpets%2Fjsonapi-mapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scoutforpets","download_url":"https://codeload.github.com/scoutforpets/jsonapi-mapper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scoutforpets%2Fjsonapi-mapper/sbom","scorecard":{"id":503744,"data":{"date":"2025-08-11","repo":{"name":"github.com/scoutforpets/jsonapi-mapper","commit":"324196f3482f5dc7581c20f9564c38474eb1fa1c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":3,"reason":"Found 7/18 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: The Unlicense: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 20 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T22:43:56.301Z","repository_id":57140320,"created_at":"2025-08-19T22:43:56.301Z","updated_at":"2025-08-19T22:43:56.301Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28332010,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"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":["bookshelf","json-api","orm","serializer"],"created_at":"2025-02-03T09:59:17.762Z","updated_at":"2026-01-12T02:20:53.400Z","avatar_url":"https://github.com/scoutforpets.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON API Mapper\n[![Build Status](https://travis-ci.org/scoutforpets/jsonapi-mapper.svg?branch=master)](https://travis-ci.org/scoutforpets/jsonapi-mapper)\n[![npm version](https://badge.fury.io/js/jsonapi-mapper.svg)](https://badge.fury.io/js/jsonapi-mapper)\n[![david dm](https://david-dm.org/scoutforpets/jsonapi-mapper.svg)](https://david-dm.org/scoutforpets/jsonapi-mapper)\n\nJSON API Mapper (_formerly Oh My JSON API_) is a wrapper around [@Seyz](https://github.com/SeyZ/)'s excellent [JSON API](http://jsonapi.org/)-compliant serializer, [jsonapi-serializer](https://github.com/SeyZ/jsonapi-serializer), that removes the pain of generating the necessary options needed to serialize each of your ORM models.\n\n[![Join the chat at https://gitter.im/scoutforpets/oh-my-jsonapi](https://badges.gitter.im/scoutforpets/jsonapi-mapper.svg)](https://gitter.im/scoutforpets/jsonapi-mapper?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n## _Breaking Changes_\nThis project has recently been renamed and rewritten using Typescript. While most functionality is generally the same, there have been a few deprecations and changes to how the Mapper is initialized. Please see the [migration guide](#migrating-from-ohmyjsonapi) below.\n\n## How does it work?\nA serializer requires some sort of 'template' to understand how to convert what you're passing in to whatever you want to come out. When you're dealing with an ORM, such as [Bookshelf](https://github.com/tgriesser/bookshelf), it would be a real pain to have to generate the 'template' for every one of your Bookshelf models in order to convert them to JSON API. JSON API Mapper handles this by dynamically analyzing your models and automatically generating the necessary 'template' to pass to the serializer.\n\n## What ORMs do you support?\nInitially, we only provide a mapper for [Bookshelf](https://github.com/tgriesser/bookshelf). However, the library can be easily extended with new mappers to support other ORMs. PR's are more than welcome!\n\n## How do I install it?\n`npm install jsonapi-mapper --save`\n\n## How do I use it?\nIt's pretty simple. You only need to configure the mapper and then use it as many times you need.\n\n```javascript\nimport Mapper = require('jsonapi-mapper');\n\n// Create the mapper\nvar mapper = new Mapper.Bookshelf('https://api.hotapp.com');\n\n// Use the mapper to output JSON API-compliant using your ORM-provided data\nreturn mapper.map(myData, 'appointment');\n```\n\n## How can I contribute?\nGod bless you if you're reading this! Check out our [Contributing page](https://github.com/scoutforpets/jsonapi-mapper/blob/master/CONTRIBUTING.md)\n\n## Migrating from OhMyJSONAPI\nThe migration process is painless:\n- Remove `oh-my-jsonapi` from your project.\n- Run `npm install jsonapi-mapper --save`\n- Convert any instances of the constructor:\n\n  ```javascript\n  new OhMyJSONAPI('bookshelf', 'https://api.hotapp.com');\n  ```\n\n  to\n\n  ```javascript\n  new Mapper.Bookshelf('https://api.hotapp.com');\n  ```\n- Convert any instances of:\n\n  ```javascript\n  jsonApi.toJSONAPI(myData, 'appointment');\n  ```\n\n  to\n\n  ```javascript\n  mapper.map(myData, 'appointment');\n  ```\n\n## API\n```javascript\nnew Mapper.Bookshelf(baseUrl, serializerOptions)\n```\n- _(optional)_ `baseUrl` _(string)_: the base URL to be used in all `links` objects returned.\n- _(optional)_ `serializerOptions` _(string)_: options to be passed to the serializer. These options will override any options generated by the mapper. For more information on the raw serializer, please [see the documentation here](https://github.com/SeyZ/jsonapi-serializer#documentation).\n\n```javascript\nmapper#map(data, type, mapperOptions)\n```\n- `data` _(object)_: The data object from Bookshelf (either a Model or a Collection) to be serialized.\n- `type` _(string)_: The type of the resource being returned. For example, if you passed in an `Appointment` model, your `type` might be `appointment`.\n- _(optional)_ `mapperOptions` _(object)_:\n  - _(optional)_ `attributes` (object):\n    - _(optional)_ `omit` _(RegExp | string)[]_: List of model attributes to omit from the resulting payload. For example, you may wish to exclude any foreign keys (as recommended by the JSON API-spec). Note: the model's `idAttribute` is automatically excluded by default.\n    - _(optional)_ `include` _(RegExp | string)[]_: List of model attributes to explicitly include from the resulting payload.\n  - _(optional)_ `keyForAttr` _(function (string =\u003e string))_: Function to customize the attributes keys. The function is passed as input the attribute key (`string`) and output the new attribute key (`string`).\n  - _(optional)_ `relations` _(boolean | object)_: Flag to enable (`true`) or disable (`false`) serializing of related models on the response. Alternatively, you can provide an object containing the following options:\n    - `included` _(boolean | string[])_ (default: `true`) - includes data for all relations in the response. You may optionally specify an array containing the names of specific relations to be included.\n    - `fields` _string[]_ - an array of relation names that should be included in the response.\n  - _(optional)_ `typeForModel` _(object | function)_: To customize the type of a relation. If the value returned is _falsy_, then it's automatically pluralized. This function **also affects** the type passed as the second parameter of the `map` function.\n    - _object_: The object should have the structure `{\"\u003crelation-name\u003e\": \"\u003ctype-to-use\u003e\"}` (e.g. `{\"best-friend\": \"people\"}`).\n    - _function (string =\u003e string)_: The function is passed as input the relation name (`string`) and output the type for that relation (`string`) (e.g. `(x) =\u003e x + '-resources'`).\n  - _(optional)_ `enableLinks` _(boolean)_: Flag to enable (`true`) or disable (`false`) the generation of links in the payload. This may be useful if the consuming system doesn't take advantage of links and you want to save on payload size and maybe a bit of performance. Defaults to `true`.\n  - _(optional)_ `query` _(object)_: An object containing the original query parameters. These will be appended to `self` and pagination links. Developer Note: This is not fully implemented yet, but following releases will fix that.\n  - _(optional)_ `pagination` _(object)_: Pagination-related parameters for building pagination links for collections.\n    - _(required)_ `offset` _(integer)_\n    - _(required)_ `limit` _(integer)_\n    - _(optional)_ `total` or `rowCount` _(integer)_\n  - _(optional)_ `meta` _(object)_: Top-level meta object to include in the document\n  - _(optional)_ `outputVirtuals` _(boolean)_: Flag to include/omit the virtuals if the `virtuals` plugin is used, overrides the default `outputVirtuals` value.\n\n# How can I contribute?\nThe project is very open to collaboration from the public, especially on providing the groundwork for other ORM's (like [Sequelize](http://docs.sequelizejs.com/) or [Mongoose](http://mongoosejs.com/)). Just open a PR!\n\nThe project source has been recently rewritten using [Typescript](http://www.typescriptlang.org/), which has been proven useful for static checks and overall development.\n\n# Credits\n- Thanks to [@Seyz](https://github.com/SeyZ/). Without his work, the project would not be possible.\n- Thanks to the [zomoz team](https://github.com/zomoz) (especially [@ShadowManu](https://github.com/shadowmanu)) for their hard work in migrating the codebase to Typescript and writing a comprehensive test suite.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscoutforpets%2Fjsonapi-mapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscoutforpets%2Fjsonapi-mapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscoutforpets%2Fjsonapi-mapper/lists"}