{"id":22439247,"url":"https://github.com/alexkander/loopback-visible-properties-mixin","last_synced_at":"2025-03-27T09:24:21.102Z","repository":{"id":42315380,"uuid":"120057872","full_name":"alexkander/loopback-visible-properties-mixin","owner":"alexkander","description":"Loopback mixin hidden all models properties and allow setup what should be visibles.","archived":false,"fork":false,"pushed_at":"2023-01-23T18:36:15.000Z","size":748,"stargazers_count":1,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-08T19:15:36.811Z","etag":null,"topics":["loopback","mixin","security","strongloop","website"],"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/alexkander.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-02-03T04:02:31.000Z","updated_at":"2022-02-11T13:34:26.000Z","dependencies_parsed_at":"2023-01-31T16:30:54.455Z","dependency_job_id":null,"html_url":"https://github.com/alexkander/loopback-visible-properties-mixin","commit_stats":null,"previous_names":["arondn2/loopback-visible-properties-mixin"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexkander%2Floopback-visible-properties-mixin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexkander%2Floopback-visible-properties-mixin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexkander%2Floopback-visible-properties-mixin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexkander%2Floopback-visible-properties-mixin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexkander","download_url":"https://codeload.github.com/alexkander/loopback-visible-properties-mixin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245815554,"owners_count":20676934,"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":["loopback","mixin","security","strongloop","website"],"created_at":"2024-12-06T01:13:25.723Z","updated_at":"2025-03-27T09:24:21.078Z","avatar_url":"https://github.com/alexkander.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"loopback-visible-properties-mixin\n===============\n\n[![npm version](https://badge.fury.io/js/loopback-visible-properties-mixin.svg)](https://badge.fury.io/js/loopback-visible-properties-mixin) [![Build Status](https://travis-ci.org/arondn2/loopback-visible-properties-mixin.svg?branch=master)](https://travis-ci.org/arondn2/loopback-visible-properties-mixin)\n[![Coverage Status](https://coveralls.io/repos/github/arondn2/loopback-visible-properties-mixin/badge.svg?branch=master)](https://coveralls.io/github/arondn2/loopback-visible-properties-mixin?branch=master)\n\nLoopback mixin hidden all models properties and allow setup what should be visibles.\n\n## Installation\n\n`npm install loopback-visible-properties-mixin --save`\n\n## Usage\n\nAdd the mixins property to your `server/model-config.json`:\n\n```json\n{\n  \"_meta\": {\n    \"sources\": [\n      \"loopback/common/models\",\n      \"loopback/server/models\",\n      \"../common/models\",\n      \"./models\"\n    ],\n    \"mixins\": [\n      \"loopback/common/mixins\",\n      \"../node_modules/loopback-visible-properties-mixin\",\n      \"../common/mixins\"\n    ]\n  }\n}\n```\n\nAdd mixin params in in model definition. Example:\n```\n{\n  \"name\": \"Person\",\n  \"properties\": {\n    \"firstName\": \"string\",\n    \"lastName\": \"string\",\n    \"email\": \"string\",\n  },\n  \"relaions\": {\n    \"siblings\": {\n      \"type\": \"referencesMany\",\n      \"model\": \"Person\",\n      \"foreignKey\": \"siblingsIds\"\n    },\n    \"mother\": {\n      \"type\": \"belongsTo\",\n      \"model\": \"Person\",\n      \"foreignKey\": \"\"\n    },\n    \"father\": {\n      \"type\": \"belongsTo\",\n      \"model\": \"Person\",\n      \"foreignKey\": \"\"\n    },\n    \"couple\": {\n      \"type\": \"belongsTo\",\n      \"model\": \"Person\",\n      \"foreignKey\": \"\"\n    },\n    \"children\": {\n      \"type\": \"hasMany\",\n      \"model\": \"Person\",\n      foreignKey: \"motherId\"\n    },\n  },\n  \"mixins\": {\n    \"VisibleProperties\": {\n      \"fields\": {\n        \"firstName\":   true,\n        \"lastName\":    true,\n        \"email\":       false,\n        \"mother\":      true,\n        \"motherId\":    false,\n        \"father\":      true,\n        \"fatherId\":    false,\n        \"siblings\":    true,\n        \"siblingsIds\": false,\n        \"children\":    true\n      }\n    }\n  }\n}\n```\n\nYou can setup this mixin with a array of visible properties too. Example:\n```\n{\n  \"name\": \"Person\",\n  ...\n  \"mixins\": {\n    \"VisibleProperties\": {\n      \"fields\": [\n        \"firstName\",\n        \"lastName\",\n        \"mother\",\n        \"father\",\n        \"siblings\",\n        \"children\",\n      ]\n    }\n  }\n}\n```\n\nIn the above definitions, the attributes `id`, `couple` and `coupleId` will not be visible in remote responses because they were ignored and `email`, `motherId`, `fatherId` and `siblingsIds` will not be visible because they were set `false`.\n\n## Troubles\n\nIf you have any kind of trouble with it, just let me now by raising an issue on the GitHub issue tracker here:\n\nhttps://github.com/arondn2/loopback-visible-properties-mixin/issues\n\nAlso, you can report the orthographic errors in the READMEs files or comments. Sorry for that, I do not speak English.\n\n## Tests\n\n`npm test` or `npm run cover`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexkander%2Floopback-visible-properties-mixin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexkander%2Floopback-visible-properties-mixin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexkander%2Floopback-visible-properties-mixin/lists"}