{"id":20627262,"url":"https://github.com/augejs/provider-scanner","last_synced_at":"2026-04-16T20:39:50.543Z","repository":{"id":40281621,"uuid":"291709206","full_name":"augejs/provider-scanner","owner":"augejs","description":"`provider-scanner` is a scan framework for nodeJs.","archived":false,"fork":false,"pushed_at":"2023-03-05T11:29:12.000Z","size":3014,"stargazers_count":2,"open_issues_count":8,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-28T10:45:08.962Z","etag":null,"topics":["provider-hook","provider-metadata","tree-structure"],"latest_commit_sha":null,"homepage":"https://augejs.github.io/provider-scanner/","language":"TypeScript","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/augejs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-31T12:28:29.000Z","updated_at":"2022-01-24T14:56:36.000Z","dependencies_parsed_at":"2024-11-16T13:16:28.020Z","dependency_job_id":"f8e5cc9f-6ad6-48e0-89a3-3affef5bda5c","html_url":"https://github.com/augejs/provider-scanner","commit_stats":{"total_commits":59,"total_committers":3,"mean_commits":"19.666666666666668","dds":0.5932203389830508,"last_synced_commit":"4cedfc4e122d824c8080b8a15506683b31d479e6"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/augejs%2Fprovider-scanner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/augejs%2Fprovider-scanner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/augejs%2Fprovider-scanner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/augejs%2Fprovider-scanner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/augejs","download_url":"https://codeload.github.com/augejs/provider-scanner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242483346,"owners_count":20135785,"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":["provider-hook","provider-metadata","tree-structure"],"created_at":"2024-11-16T13:16:15.600Z","updated_at":"2026-04-16T20:39:50.499Z","avatar_url":"https://github.com/augejs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![npm version](https://badge.fury.io/js/%40augejs%2Fprovider-scanner.svg)](https://badge.fury.io/js/%40augejs%2Fprovider-scanner)\n\n\nhttps://augejs.github.io/provider-scanner/\n\n`provider-scanner` is a  Provider's metadata scan framework for nodeJs which is base on javascript `Reflect.defineMetadata`.\n\n### Installation\n\nYou can get the latest release and the type definitions using npm:\n\n```javascript\nnpm install @augejs/provider-scanner reflect-metadata --save\n```\n\n### What is a `Provider`\n\nTo be honest, I don't know what a `Provider` exactly is. Maybe an Entity, a File, a structure, a component, a service, or a string. What ever, it can be defined with kinds of metadata.\n\nThe `provider-scanner` just focus on the scan process with kinds of metadata. Finally the result is what we want.\n\n```javascript\nimport { Metadata } from '@augejs/provider-scanner';\n\nconst employee = {\n  fullName: 'xxxx',\n  age: 12,\n  headImageUrl: 'xxxx',\n};\n// here the employee structure consider as a provider\n\nMetadata.defineMetadata(Metadata, \n{\n  reporter: 'xxx',\n  messageOwner: 'xxx'\n}, employee);\n\n// here we add a metadata to the employee structure.\n```\n\nA `Provider` can store kinds of `metadata` by using `Reflect.defineMetadata`.  (Also this behavior can be used by `Decorator`). \n\n![provider model](./docs/assets/provider-model.png)\n\n### Organize Provider\n\nLet's take a look at below diagram,  it a tree of `Provider`,  I think the tree structure is a good idea to organize things, thinking about the user-interface elements,  it's a tree structure. thinking about the computer file system, it's a tree structure.\n\n![provider tree](./docs/assets/provider-tree.png)\n\n\u003e If the diagram means a school then the `Provider` means teachers and students. \n\u003e\n\u003e If the diagram means a program then the `Provider` means logic unit.\n\n### ParentMetadata\n\nHere is a `Parent Metadata` which can define the children metadata to `Provider`\n\n```javascript\nimport { ParentMetadata } from '@augejs/provider-scanner';\n\nconst employee = {\n  fullName: 'xxxx',\n  age: 12,\n  headImageUrl: 'xxxx',\n};\n// here the employee structure consider as a provider\n\nconst manager = {\n  fullName: 'xxxx',\n  age: 54,\n  headImageUrl: 'xxxx',\n};\n// here the manager structure consider as a provider\n\nParentMetadata.defineMetadata( \n[\n  employee,\n], manager);\n// here we add the employee to the manager as this child node.\n\n// we can easily use the `ParentMetadata` to build a tree structure which is composite of `providers` just the above diagram.\n```\n\n### HookMetadata\n\nHere is a `HookMetadata` which can define the metadata `hooks` to `Provider`.\nAnd the hook will execute in scan process.\n\n![hook-metadata](./docs/assets/scan-hook-metadata.png)\n\n#### Single Provider Hooks Execute Model\n\nGo back to `Provider` , Maybe we need do some logic process  on `Provider` maybe process data, create new object, etc.  The below diagram show the idea. Each logic process is call a `hook`, hook can be nested, and all hooks of `Provider` share the data structure `ScanNode`  which can store some process results for current `Provider` \n\n\n\n![provider-hook](./docs/assets/provider-hook.png)\n\n\u003e The hook execute order is A hook1-pre -\u003e A hook2-pre -\u003e A hook2-after-\u003eA hook1-after \n\n\nThe `hook` idea here is from KOA, it just a middleware in KOA.\n\n``` \nasync (context: any, next:Function) {\n  // some logic before\n  await next();\n  // some logic after\n}\n```\n\n\u003e The context here can get the current process ScanNode.\n\n\n![Onion](./docs/assets/Onion.png)\n\n\n\u003e Maybe this diagram can explain how a middleware works.\n\n#### Sibling Provider Hooks Execute Model\n\nProvider C is sibling of provide B\n\n![sibling-provider-hook](./docs/assets/sibling-provider-hook.png)\n\n\u003e The hook execute order is  B hooks -\u003e C hooks\n\n#### Parent Provider Hooks Execute Model\n\nProvider A is parent of Provider B\n\n![parent-provider-hook](./docs/assets/parent-provider-hook.png)\n\n\u003e The hook execute order is is A hook1-pre -\u003e A hook2-pre -\u003e  ***B hooks***    -\u003e A hook2-after-\u003eA hook1-after \n\u003e\n\u003e the B  hooks seem is inner A\n\nSo finally, the scanner go through the provider tree and execute all the hooks around the provide. You can do every thing you want base on provider metadata and hooks to build anything.\n\n![scan-execute-order](./docs/assets/scan-execute-order.png)\n\n\u003e This is the `Provide Tree`(above diagram) scan execute order. It's like program  function execute process right?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faugejs%2Fprovider-scanner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faugejs%2Fprovider-scanner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faugejs%2Fprovider-scanner/lists"}