{"id":16718212,"url":"https://github.com/allouis/indexjs","last_synced_at":"2025-07-29T05:34:23.747Z","repository":{"id":16172428,"uuid":"18918736","full_name":"allouis/indexjs","owner":"allouis","description":"handy index.js helper for multiple files","archived":false,"fork":false,"pushed_at":"2016-06-16T08:29:27.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-25T12:07:19.243Z","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/allouis.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":"2014-04-18T16:35:46.000Z","updated_at":"2016-06-15T16:57:07.000Z","dependencies_parsed_at":"2022-09-03T00:02:10.718Z","dependency_job_id":null,"html_url":"https://github.com/allouis/indexjs","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/allouis/indexjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allouis%2Findexjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allouis%2Findexjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allouis%2Findexjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allouis%2Findexjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allouis","download_url":"https://codeload.github.com/allouis/indexjs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allouis%2Findexjs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267633670,"owners_count":24118777,"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-29T02:00:12.549Z","response_time":2574,"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":[],"created_at":"2024-10-12T21:35:41.108Z","updated_at":"2025-07-29T05:34:23.716Z","avatar_url":"https://github.com/allouis.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# indexjs [![Build Status](https://travis-ci.org/allouis/indexjs.svg?branch=master)](https://travis-ci.org/allouis/indexjs)\n\nYou can use indexjs to simplify the requiring of similar modules within a directory, for examples models;\n\n## API\n\n### `indexjs(directory, output, [transform])`\ndirectory will usually be __dirname, when run from index.js of a directory.\n\noutput can be either an array or an object, it doesn't have to be empty.\n\ntransform is an optional function that gets called on all the required modules, the return value is used instead of the module\n\n## Usage\n\n### File structure\n\n```\n-- app.js\n-- models/\n----- index.js\n----- user.js\n----- comment.js\n----- post.js\n----- .hiddenfile\n-- routers/\n----- index.js\n----- user.js\n----- comment.js\n----- post.js\n\n```\n### models/index.js\n```javascript\n\n/**\n * /project/models/index.js\n */\n\nvar indexjs = require('indexjs');\nmodule.exports = indexjs(__dirname, {}, function (model) {\n  return model.init(); // example of transform\n});\n```\n### routers/index.js\n```javascript\n\n/**\n * /project/routers/index.js\n */\n\nvar indexjs = require('indexjs');\nmodule.exports = indexjs(__dirname, []);\n```\n### app.js\n```javascript\n\n/**\n * /project/app.js\n */\n \nvar models = require('./models');\nvar routers = require('./routers');\nrouters.forEach(function(router) {\n router(app);\n});\n\nmodels.user; // the equivalent of require('./models/user');\nmodels.comment; // the quivalent of require('./models/comment');\n// etc..\nmodels['.hiddenfile']; // undefined;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallouis%2Findexjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallouis%2Findexjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallouis%2Findexjs/lists"}