{"id":18897287,"url":"https://github.com/iagocalazans/composite-modules","last_synced_at":"2025-08-14T11:35:52.193Z","repository":{"id":57204942,"uuid":"407648629","full_name":"iagocalazans/composite-modules","owner":"iagocalazans","description":"A module loader structure implemented using Composite Pattern.","archived":false,"fork":false,"pushed_at":"2021-09-22T16:20:52.000Z","size":58,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-24T07:39:48.127Z","etag":null,"topics":["base","composite-pattern","framework","module","modules","pattern","simple","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/composite-modules","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/iagocalazans.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":"2021-09-17T18:52:13.000Z","updated_at":"2021-09-22T16:23:13.000Z","dependencies_parsed_at":"2022-09-18T00:50:47.176Z","dependency_job_id":null,"html_url":"https://github.com/iagocalazans/composite-modules","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/iagocalazans/composite-modules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iagocalazans%2Fcomposite-modules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iagocalazans%2Fcomposite-modules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iagocalazans%2Fcomposite-modules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iagocalazans%2Fcomposite-modules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iagocalazans","download_url":"https://codeload.github.com/iagocalazans/composite-modules/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iagocalazans%2Fcomposite-modules/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267384036,"owners_count":24078573,"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-07-27T02:00:11.917Z","response_time":82,"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":["base","composite-pattern","framework","module","modules","pattern","simple","typescript"],"created_at":"2024-11-08T08:36:52.715Z","updated_at":"2025-07-27T16:09:00.491Z","avatar_url":"https://github.com/iagocalazans.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eWelcome to Composite Modules 👋\u003c/h1\u003e\n\n\u003cp\u003e\n  \u003cimg alt=\"Version\" src=\"https://img.shields.io/badge/version-1.0.5-blue.svg?cacheSeconds=2592000\" /\u003e\n  \u003cimg src=\"https://img.shields.io/badge/node-14.x-blue.svg\" /\u003e\n  \u003ca href=\"#\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Documentation\" src=\"https://img.shields.io/badge/documentation-no-red.svg\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n### This module facilitates the usage of a Composite based module structure on your system.\n\n## Install\nyarn users:\n```sh\nyarn add composite-modules\n```\nnpm users:\n```sh\nnpm install composite-modules\n```\n\nImporting:\n```js\nimport { ModulesContainer } from 'composite-modules'\n```\n\n---\n\n## Usage:\n\n### Common application, normal structure.  \n\nYou should use the default ModuleContainer and add all the modules you created to it.\n\n```js\nconst unamedComposite = new ModuleUnamed('unamed');\nconst anotherUnamedComposite = new AnotherModuleUnamed('anotherUnamed');\nconst simpleModule = new SimpleUnamedModule('simpleUnamed');\n\nanotherUnamedComposite.add(simpleModule);\nunamedComposite.add(anotherUnamedComposite);\nModulesContainer.add(unamedComposite);\n\nvoid ModulesContainer.init();\n\nModulesContainer.events.on('ready', (modules) =\u003e {\n    // Here we ensure that all of your modules have been loaded and you can access them.\n    modules.collection.use('anotherUnamed').anotherFunction()\n\n    ...\n})\n\n```\n\n### To create your Module, extend the CompositeModule or the SimpleModule.\n\nYou need to extend the CompositeModule or SimpleModule modules, creating from them the modules you want to add to the module tree. \n\nRemembering that the CompositeModule can have child modules. These will normally be loaded into the structure, as long as they are added correctly. \n\n```js\nexport class ModuleUnamed extends CompositeModule {\n    // You can add as many properties as you need... \n    private myProperty: any;\n    public myPropertyTwo: any;\n\n    // As a standard you always need to pass a name as parameter.\n    constructor(name: string, yourParams: any) {\n        super(name); // Must always pass name as super call.\n\n        // Your constructor definitions goes here...\n        ...\n    }\n\n    async load (): Promise\u003cvoid\u003e {\n        this.beautyLogs.info('Loading this structures...');\n        \n        // Your loading definitions goes here...\n        ...\n\n        this.beautyLogs.success('Loaded this structures...');\n    }\n\n    async unload (): Promise\u003cvoid\u003e {\n        this.beautyLogs.info('Unoading this structures...');\n\n        // Your unload definitions goes here...\n        ...\n\n        this.beautyLogs.success('Unloaded this structures...');\n    }\n}\n```\n\nI recommend using `this.beautyLogs` for logs, it displays logs in a pattern and pretty like this (with colors):\n\n```sh\n2021-09-22T15:28:41.218Z (system) [Container]: [*] System is starting...\n2021-09-22T15:28:41.220Z (info) [SimpleUnamedModule]: Loading this structures...\n2021-09-22T15:28:41.220Z (success) [SimpleUnamedModule]: Loaded this structures...\n2021-09-22T15:28:41.220Z (info) [AnotherModuleUnamed]: Loading this structures...\n2021-09-22T15:28:41.221Z (info) [ModuleUnamed]: Loading this structures...\n2021-09-22T15:28:41.221Z (success) [ModuleUnamed]: Loaded this structures...\n```\n\n\n---\n\n\n## Author\n\n👤 **Iago Calazans** (💼 *Senior Node | TypeScript Developer*)\n\n* Website: https://iagocalazans.github.io/\n* GitHub: https://github.com/iagocalazans/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiagocalazans%2Fcomposite-modules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiagocalazans%2Fcomposite-modules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiagocalazans%2Fcomposite-modules/lists"}