{"id":27352426,"url":"https://github.com/fiws/hapi-forest","last_synced_at":"2025-10-11T04:50:29.000Z","repository":{"id":57260893,"uuid":"69751377","full_name":"fiws/hapi-forest","owner":"fiws","description":"Generate REST routes \u0026 handlers with your mongoose models for hapi.","archived":false,"fork":false,"pushed_at":"2024-01-25T15:27:27.000Z","size":259,"stargazers_count":4,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-21T03:31:35.710Z","etag":null,"topics":["api","hapi","mongoose","rest"],"latest_commit_sha":null,"homepage":null,"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/fiws.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-10-01T17:02:19.000Z","updated_at":"2023-02-28T21:14:32.000Z","dependencies_parsed_at":"2025-04-12T20:55:22.312Z","dependency_job_id":"06613016-e863-4ff3-8b08-fe884cc99bd6","html_url":"https://github.com/fiws/hapi-forest","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/fiws/hapi-forest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiws%2Fhapi-forest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiws%2Fhapi-forest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiws%2Fhapi-forest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiws%2Fhapi-forest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fiws","download_url":"https://codeload.github.com/fiws/hapi-forest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiws%2Fhapi-forest/sbom","scorecard":{"id":401841,"data":{"date":"2025-08-11","repo":{"name":"github.com/fiws/hapi-forest","commit":"6dda115c54d591ad027999c052c2e166fd16a4c5"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 2/23 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/nodejs.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/fiws/hapi-forest/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/fiws/hapi-forest/nodejs.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/fiws/hapi-forest/nodejs.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/nodejs.yml:29","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 10 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T20:14:55.248Z","repository_id":57260893,"created_at":"2025-08-18T20:14:55.248Z","updated_at":"2025-08-18T20:14:55.248Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276668522,"owners_count":25683073,"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-09-23T02:00:09.130Z","response_time":73,"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":["api","hapi","mongoose","rest"],"created_at":"2025-04-12T20:55:18.093Z","updated_at":"2025-10-11T04:50:28.969Z","avatar_url":"https://github.com/fiws.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"hapi-forest\n===========\n\n[![package on npm](https://img.shields.io/npm/v/hapi-forest.svg)](https://www.npmjs.com/package/hapi-forest)\n[![Travis branch](https://img.shields.io/travis/fiws/hapi-forest/master.svg)](https://travis-ci.org/fiws/hapi-forest)\n![node 8+ required](https://img.shields.io/badge/node-8%2B-brightgreen.svg)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/fiws/hapi-forest/master/LICENSE)\n\n![A FOREST](https://i.imgur.com/5l9cVaD.png)\n\nProvides REST handlers for mongoose models. Can also generate ready to use\nroutes, for fast bootstrapping.\n\n## Quickstart\n\n1. Install it\n  ```shell\n  npm i --save hapi-forest # or yarn add hapi-forest if you prefer\n  ```\n\n2. Register the plugin.\n  ```JavaScript\n  // register hapi-forest\n  server.register({\n    register: require('hapi-forest'),\n    options: {\n      // add your models here for auto route generation\n      bootstrap: [ require('./models/user-model') ]\n    }\n  });\n  ```\n\n3. Test your dynamically generated REST endpoints. [hapi-swagger](https://github.com/glennjones/hapi-swagger) works nicely with hapi-forest.\n\nTake a look at the `example` directory for a full example.\n\n## Plugin options\n\n* `bootstrap: [ MongooseModel, MongooseModel, … ]`\n\n  Will generate ready to use CRUD routes. hapi-forest will attempt to generate a basic\n  joi schema based on the model.\n\n## Handlers\n\nYou can use the `forest` handler and define your own routes, instead of auto-generating\nthem. This is useful if you need more control over your endpoints or want custom validation.\n\nThe forest handler behaves differently based on your route definition.\n`GET`, `POST`, `PATCH` \u0026 `PUT` are supported.\n\n#### URL parameter\n\nFor routes like `GET /collection/{name}`, the first URL parameter (`name` in this case)\nis used as the \"id\". It will be used in the condition of the mongoose query.\n\n`{id}` will translate to `_id` for convenience.\n\n#### Generic Options for all methods\n\nOption              | Description\n:------------------ | :--------------------------------------------------------------------------------------\n`model`             | **required** – The mongoose Model for this route.\n`type`              | Overwrites the auto selected handler. Can be one of `getOne, getAll, post, put, delete`\n`preQuery`          | A `Function` that gets passed the current mongoose query, that was generated by forest.\n`transformResponse` | A `Function` that gets passed the response. You have to return the modified response.\n\n\n\n### `getOne`\n\nReturns all documents from the specified `model`.\n\n* Only custom fields can be selected using `select`.\n* the first parameter in the path (`name` in this example) will be used to query\n\n```JavaScript\nserver.route({\n  method: 'GET',\n  path: '/users/{name}',\n  handler: {\n    forest: {\n      model: User,\n    }\n  }\n});\n\n\n```\n\n### `getAll`\n\nReturns all documents from the specified `model`. The result will be streamed.\n\n* Only custom fields can be selected using `select`.\n* The `filterByQuery` option allows basic filtering of the results by sending a\nquery with the request. (`?group=nodejs\u0026role=developer`)\n  * the query that results from the user input can be modified with the `transformQuery` option.\n  You can specify a function that has to return the updated query.\n* The `allowLimit` option gives the client the ability to limit the number of results by\nadding `$limit=x` to the query parameters.\n\n```JavaScript\nserver.route({\n  method: 'GET',\n  path: '/users',\n  handler: {\n    forest: {\n      model: User,\n      select: 'firstName group lastName birthday',\n    }\n  }\n});\n```\n\n### `post`\n\nCreates a new document.\n\n* `skipMongooseHooks` will use a faster mongoose create implementation, skipping all hooks.\n\n```JavaScript\nserver.route({\n  method: 'POST',\n  path: '/users',\n  handler: {\n    forest: {\n      model: User\n    }\n  }\n});\n```\n\n### `put`\n\nUpdates an existing document or creates a new document if it does not exist.\nFor now an update will **not** overwrite and existing document but only update it,\nlike `patch` does.\n\n* you can disallow creating new documents with `allowUpsert: false`. PUT will behave like PATCH in that case.\n\n```JavaScript\nserver.route({\n  method: 'PUT',\n  path: '/users/{name}',\n  handler: {\n    forest: {\n      model: User,\n      allowUpsert: true,\n    }\n  }\n});\n```\n\n### `delete`\n\nDeletes a document.\n\n* the first parameter in the path (`name` in this example) will be used to query\n\n```JavaScript\nserver.route({\n  method: 'DELETE',\n  path: '/users/{name}',\n  handler: {\n    forest: {\n      model: User,\n    }\n  }\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiws%2Fhapi-forest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffiws%2Fhapi-forest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiws%2Fhapi-forest/lists"}