{"id":20048726,"url":"https://github.com/leaf4monkey-npm/candy-box","last_synced_at":"2025-10-30T08:23:20.141Z","repository":{"id":52137924,"uuid":"111212877","full_name":"leaf4monkey-npm/candy-box","owner":"leaf4monkey-npm","description":null,"archived":false,"fork":false,"pushed_at":"2021-05-06T23:26:28.000Z","size":5118,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-29T23:37:59.151Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leaf4monkey-npm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-18T14:40:34.000Z","updated_at":"2020-07-16T08:55:09.000Z","dependencies_parsed_at":"2022-08-23T21:51:06.416Z","dependency_job_id":null,"html_url":"https://github.com/leaf4monkey-npm/candy-box","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/leaf4monkey-npm/candy-box","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaf4monkey-npm%2Fcandy-box","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaf4monkey-npm%2Fcandy-box/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaf4monkey-npm%2Fcandy-box/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaf4monkey-npm%2Fcandy-box/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leaf4monkey-npm","download_url":"https://codeload.github.com/leaf4monkey-npm/candy-box/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaf4monkey-npm%2Fcandy-box/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262685443,"owners_count":23348420,"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":[],"created_at":"2024-11-13T11:45:42.039Z","updated_at":"2025-10-30T08:23:20.046Z","avatar_url":"https://github.com/leaf4monkey-npm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Candy-Box\n\nManage your modules classify, and provide Dependency Injection for them.\n\n## Features\n\n- Auto load the modules in the directories you assign.\n\n- Provide DI for the registered modules.\n\n- Prevent the registered modules to be retrieved directly.\n\n## Get Started\n\n1. Install `candy-box`:\n\n    ```bash\n    $ npm i candy-box\n    ```\n\n2. Write your configs in a `candyboxrc.json`:\n\n    candyboxrc.json:\n\n    ```json\n    {\n      \"injectSelf\": true, // Inject itself to the modules of a provided context, default `true`.\n      \"camelCaseKey\": true, // Change name of module and context to be \"camelCase\", default `true`.\n      \"capitalizeInitial\": { // Capitalize the initial letter of a name, only active when `camelCaseKey` is true, default `true`.\n        \"module\": true, // Active on module name, default `true`.\n        \"contextKey\": true // Active on context name, default `true`.\n      },\n      \"oneWayDependency\": true, // One-way dependencies, default `true`.\n      \"context\": {\n        \"./path/to/dir1\": {\n          \"injectSelf\": false, // Rewrite `config.injectSelf` locally.\n          \"camelCaseKey\": true, // Rewrite `config.camelCaseKey` locally.\n          \"capitalizeInitial\": true, // Rewrite `config.capitalizeInitial` locally.\n          \"name\": \"DAOs\" // Rewrite the context name.\n          // \"dependencies\": [\"Dir2\"], // Illegal dependencies.\n        },\n        \"./path/to/dir2\": {\n          \"dependencies\": [\"Dir1\"],\n          \"skip\": [\"Module2\"], // Skip loading the assigned modules.\n          \"childrenConfigs\": {\n            \"User\": {\n              \"dependencies\": [\"Dir1.Module1\"],\n              \"mergeDependencies\": false\n            }\n          }\n        }\n      }\n    }\n    ```\n\n3. Define your modules in the directories you assigned in configs, for example:\n\n    dir1/module1.js:\n\n    ```js\n    module.exports = ctx =\u003e {\n        let Dir1;\n        ctx.onInitialized(() =\u003e {\n            Dir1 = ctx.Dir1; // Yes, you can get the modules under the \"dir1\".\n        });\n        return {\n            fn () {\n                // your bussiness code.\n                return 'dir1/module1';\n            }\n        };\n    };\n    ```\n\n    dir2/module1.js:\n\n    ```js\n    // const Dir1Module1 = require('path/to/dir1/module1'); // Cannot get the correct module.\n\n    module.exports = ctx =\u003e {\n        let Dir1;\n        ctx.onInitialized(() =\u003e {\n            Dir1 = ctx.Dir1;\n        });\n        return {\n            fn () {\n                // your bussiness code.\n                console.log(Dir1.Module1.fn()); // dir1/module1\n            }\n        };\n    };\n    ```\n\n4. Load your configs on starting up.\n\n    startup.js\n    ```js\n    const loader = require('candy-box');\n    const path = require('path');\n\n    loader(path.resolve('.')); // Assume you `candyboxrc.json` file is in the current path.\n    ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleaf4monkey-npm%2Fcandy-box","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleaf4monkey-npm%2Fcandy-box","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleaf4monkey-npm%2Fcandy-box/lists"}