{"id":15066189,"url":"https://github.com/rxstack/mongoose-service","last_synced_at":"2026-02-15T23:02:35.577Z","repository":{"id":34068084,"uuid":"167562023","full_name":"rxstack/mongoose-service","owner":"rxstack","description":"MongooseService for @rxstack/platform","archived":false,"fork":false,"pushed_at":"2024-10-29T10:25:43.000Z","size":635,"stargazers_count":1,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-17T23:32:01.594Z","etag":null,"topics":["mongodb","mongoose","nodejs","platform","rxstack","typescript"],"latest_commit_sha":null,"homepage":"","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/rxstack.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}},"created_at":"2019-01-25T14:42:29.000Z","updated_at":"2024-10-29T10:24:45.000Z","dependencies_parsed_at":"2023-01-15T04:22:09.679Z","dependency_job_id":"b690f13d-ad0a-4d12-80a3-3ddb829e3f10","html_url":"https://github.com/rxstack/mongoose-service","commit_stats":{"total_commits":32,"total_committers":2,"mean_commits":16.0,"dds":0.03125,"last_synced_commit":"f656962b93c112d567211344598eaec5bfbf824c"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/rxstack/mongoose-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxstack%2Fmongoose-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxstack%2Fmongoose-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxstack%2Fmongoose-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxstack%2Fmongoose-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rxstack","download_url":"https://codeload.github.com/rxstack/mongoose-service/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxstack%2Fmongoose-service/sbom","scorecard":{"id":791606,"data":{"date":"2025-08-11","repo":{"name":"github.com/rxstack/mongoose-service","commit":"4256a9acdc9995e7eeb9ee4fdfe7d7d8ae0d6672"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"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":"Code-Review","score":0,"reason":"Found 0/30 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":"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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/node.js.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":"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":"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":"Pinned-Dependencies","score":2,"reason":"dependency not pinned by hash detected -- score normalized to 2","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/rxstack/mongoose-service/node.js.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/rxstack/mongoose-service/node.js.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/node.js.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/rxstack/mongoose-service/node.js.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/node.js.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/rxstack/mongoose-service/node.js.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/node.js.yml:37","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   1 out of   2 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":"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":"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":"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":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'","Warn: branch protection not enabled for branch 'legacy-mongodb-3.4'"],"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 5 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"}},{"name":"Vulnerabilities","score":3,"reason":"7 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-7q7g-4xm8-89cq","Warn: Project is vulnerable to: GHSA-xffm-g5w8-qvg7","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-m7xq-9374-9rvx","Warn: Project is vulnerable to: GHSA-vg7j-7cwx-8wgw"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T07:42:25.813Z","repository_id":34068084,"created_at":"2025-08-23T07:42:25.814Z","updated_at":"2025-08-23T07:42:25.814Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29491998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T19:29:10.908Z","status":"ssl_error","status_checked_at":"2026-02-15T19:29:10.419Z","response_time":118,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["mongodb","mongoose","nodejs","platform","rxstack","typescript"],"created_at":"2024-09-25T01:03:09.705Z","updated_at":"2026-02-15T23:02:35.546Z","avatar_url":"https://github.com/rxstack.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The RxStack Mongoose Service\n\n[![Node.js CI](https://github.com/rxstack/mongoose-service/actions/workflows/node.js.yml/badge.svg?branch=master)](https://github.com/rxstack/mongoose-service/actions/workflows/node.js.yml)\n[![Maintainability](https://api.codeclimate.com/v1/badges/f4b78bc8f5a0dc0d9915/maintainability)](https://codeclimate.com/github/rxstack/mongoose-service/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/f4b78bc8f5a0dc0d9915/test_coverage)](https://codeclimate.com/github/rxstack/mongoose-service/test_coverage)\n\n\u003e Mongoose service that implements [@rxstack/platform adapter API and querying syntax](https://github.com/rxstack/rxstack/tree/master/packages/platform#services).\n\n\u003e This adapter also requires a running [MongoDB database server](https://docs.mongodb.com/manual/tutorial/getting-started/#).\n\n## Table of content\n\n- [Installation](#installation)\n- [Setup](#setup)\n- [Module Options](#module-options)\n- [Service Options](#service-options)\n- [Usage](#usage)\n    - [Create interfaces](#usage-create-interfaces)\n    - [Create mongoose schemas](#usage-schemas)\n    - [How to use in controller](#usage-controller)\n- [Commands](#commands)\n    - [Ensure Endexes](#commands-ensure-indexes)\n    - [Drop Database](#commands-drop-database)\n- [Validation Observer](#validation-observer)\n\n\n## \u003ca name=\"installation\"\u003e\u003c/a\u003e Installation\n\n```\nnpm install @rxstack/mongoose-service --save\n```\n\n## \u003ca name=\"setup\"\u003e\u003c/a\u003e  Setup\n`MongooseServiceModule` needs to be registered in the `application`. Let's create the application:\n\n```typescript\nimport {Application, ApplicationOptions} from '@rxstack/core';\nimport {MongooseServiceModule} from '@rxstack/mongoose-service';\n\nexport const APP_OPTIONS: ApplicationOptions = {\n  imports: [\n    MongooseServiceModule.configure({\n      connection: {\n        uri: process.env.MONGO_HOST, // mongodb://localhost:27017/test\n        // mongoose options\n        options: { }\n      },\n    })\n  ],\n  providers: [\n    // ...\n  ]\n};\n\nnew Application(APP_OPTIONS).start();\n```\n\n## \u003ca name=\"module-options\"\u003e\u003c/a\u003e Module Options\n\n- `connection.url`: mongodb server uri\n- `connection.options`: mongoose options (optional)\n- `logger.enabled`: enable query logging (defaults to false)\n- `logger.level`: logging level (defaults to debug)\n\n## \u003ca name=\"service-options\"\u003e\u003c/a\u003e Service Options\nIn addition to [service base options](https://github.com/rxstack/rxstack/tree/master/packages/platform#services)\nwe need to set the following options:\n\n- `model`: [mongoose model](https://mongoosejs.com/docs/models.html)\n\n## \u003ca name=\"usage\"\u003e\u003c/a\u003e  Usage\n\n### \u003ca name=\"usage-create-interfaces\"\u003e\u003c/a\u003e  Create interfaces\nFirst we need to create `model interface` and `InjectionToken`:\n\n```typescript\nimport {InjectionToken} from 'injection-js';\nimport {MongooseService} from '@rxstack/mongoose-service';\n\nexport interface Product {\n  id: string;\n  name: string;\n}\n\nexport const PRODUCT_SERVICE = new InjectionToken\u003cMongooseService\u003cProduct\u003e\u003e('PRODUCT_SERVICE');\n```\n\n### \u003ca name=\"usage-schemas\"\u003e\u003c/a\u003e Create mongoose schemas\n\n```typescript\nimport { Schema } from 'mongoose';\nconst { v4: uuid } = require('uuid');\n\nexport const productMongooseSchema = new Schema({\n  _id: {\n    type: String,\n    default: uuid\n  },\n  name: {\n    type: String,\n    unique: true,\n    required: true,\n  }\n}, {_id: false, versionKey: false });\n```\n\nthen register the service in the application provides:\n\n```typescript\nimport {ApplicationOptions} from '@rxstack/core';\nimport {MongooseService} from '@rxstack/mongoose-service';\nimport {Connection} from 'mongoose';\n\nexport const APP_OPTIONS: ApplicationOptions = {\n  // ...\n  providers: [\n    {\n      provide: PRODUCT_SERVICE,\n      useFactory: (conn: Connection) =\u003e {\n        return new MongooseService({\n          idField: '_id', defaultLimit: 25, model: conn.model('Product', productMongooseSchema)\n        });\n      },\n      deps: [Connection],\n    },\n  ]\n};\n```\n\n### \u003ca name=\"usage-controller\"\u003e\u003c/a\u003e How to use in controller\n\n\n```typescript\nimport {Connection} from 'mongoose';\nimport {Injectable} from 'injection-js';\nimport {Http, Request, Response, WebSocket, InjectorAwareInterface} from '@rxstack/core';\n\n@Injectable()\nexport class ProductController implements InjectorAwareInterface {\n\n  @Http('POST', '/product', 'app_product_create')\n  @WebSocket('app_product_create')\n  async createAction(request: Request): Promise\u003cResponse\u003e {\n    // getting connection\n    const connection = injector.get(Connection);\n   \n    // standard use\n    const service = this.injector.get(PRODUCT_SERVICE);\n    await service.insertOne(request.body);\n  }\n}\n```\n\n[Read more about platform services](https://github.com/rxstack/rxstack/tree/master/packages/platform#services)\n\n## \u003ca name=\"commands\"\u003e\u003c/a\u003e  Commands\nHelpful commands managing your mongoose database\n\n### \u003ca name=\"commands-ensure-endexes\"\u003e\u003c/a\u003e Ensure Indexes\nMakes the indexes in MongoDB match the indexes defined in this model's schema\n\n```bash\nnpm run cli mongoose:ensure-indexes\n```\n\n### \u003ca name=\"commands-drop-database\"\u003e\u003c/a\u003e Drop databases\nDrop databases, collections and indexes for your documents.\n\n```bash\nnpm run cli mongoose:drop\n```\n\n## \u003ca name=\"validation-observer\"\u003e\u003c/a\u003e  Validation Observer\n`ValidationObserver` converts mongoose errors to `BadRequestException`.\n\nIn order to return proper validation errors and status code `400 ` we catch the exception and throw `BadRequestException`.\nThe error messages can be accessed `exception.data['errors']` and implement [`ValidationError[]`](https://github.com/rxstack/rxstack/tree/master/packages/platform/src).\n\n## License\n\nLicensed under the [MIT license](LICENSE).\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxstack%2Fmongoose-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frxstack%2Fmongoose-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxstack%2Fmongoose-service/lists"}