{"id":19214932,"url":"https://github.com/carekit-apple/ibm-hyperprotectmbaas","last_synced_at":"2025-05-12T23:21:49.190Z","repository":{"id":45442601,"uuid":"252594418","full_name":"carekit-apple/IBM-HyperProtectMBaaS","owner":"carekit-apple","description":"The IBM Hyper Protect Mobile-backend-as-a-Service for CareKit, runs on IBM Hyper Protect Virtual Servers and is a mediator between the iOS SDK and IBM Hyper Protect DBaaS","archived":false,"fork":false,"pushed_at":"2021-12-13T19:56:02.000Z","size":113,"stargazers_count":9,"open_issues_count":3,"forks_count":6,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-20T19:37:13.390Z","etag":null,"topics":["firebase","hipaa","mbaas","mongodb"],"latest_commit_sha":null,"homepage":"http://ibm.biz/hyperprotectservices","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carekit-apple.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-03T00:23:37.000Z","updated_at":"2024-03-12T12:45:59.000Z","dependencies_parsed_at":"2022-07-15T15:17:20.545Z","dependency_job_id":null,"html_url":"https://github.com/carekit-apple/IBM-HyperProtectMBaaS","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carekit-apple%2FIBM-HyperProtectMBaaS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carekit-apple%2FIBM-HyperProtectMBaaS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carekit-apple%2FIBM-HyperProtectMBaaS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carekit-apple%2FIBM-HyperProtectMBaaS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carekit-apple","download_url":"https://codeload.github.com/carekit-apple/IBM-HyperProtectMBaaS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253838090,"owners_count":21972091,"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":["firebase","hipaa","mbaas","mongodb"],"created_at":"2024-11-09T14:11:58.420Z","updated_at":"2025-05-12T23:21:49.159Z","avatar_url":"https://github.com/carekit-apple.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IBM Hyper Protect MBaaS\n\nThe IBM Hyper Protect Mobile-Backend-as-a-Service (MBaaS) is a mediator between the [IBM Hyper Protect SDK for CareKit](https://github.com/carekit-apple/IBM-HyperProtectSDK) and IBM Hyper Protect DBaaS. It must run on IBM Hyper Protect Virtual Servers to prevent this from becoming the weak link in your topology.\n\n_Note, this is a pre-1.0 release and is still in alpha_\n\n### Roadmap\n\n- [ ] Logging with log4js\n- [ ] OAuth2 support with JWT\n- [ ] Bi-directional Synchronization of other high level entities (Contact, CarePlan, Patient)\n- [ ] Comprehensive integration tests\n- [ ] Comprehensive system tests\n- [ ] OpenAPI Specification template\n- [ ] IBM Cloud Starter Kit support\n- [ ] Travis Build Support\n- [ ] Large object support ( \u003e 16 MB)\n\n## Instructions to build and run\n\n\u003e WORK IN PROGRESS\n\n- Ensure you have a MongoDB instance either on [IBM Cloud via Hyper Protect DBaaS](https://www.ibm.com/cloud/hyper-protect-dbaas) or locally (steps below).\n- `npm install` to install dependencies\n- `npm start` to run\n\nBy default, it hosts on port 3000, and expects MongoDB to be available at the default port : 27017. These can be changed in [config.json](./config/config.json) and [ormconfig.json][./ormconfig.json] respectively.\n\nDatabase connectivity is provided using Typeorm + the official MongoDB JavaScript client. The database can be changed by switching the metadata on main entities in the the `src/entity/*.ts` to match noSQL (ObjectID, ObjectIDColumn() etc) or Relational (PrimaryGeneratedColumn() etc) and then switching the database name in typeorm. More info:\n\nType ORM requires database connectivity information either in code or reads from ormconfig.json at the project root by default. For connections involving ssl certs, configuration in code is the only option. \n\n\nFrom the Hyper Protect DBaaS Dashboard, copy the connection url. It will look similar to\n`mongodb://dbaasXX.hyperp-dbaas.cloud.ibm.com:XXXX,dbaasYY.hyperp-dbaas.cloud.ibm.com:YYYY,dbaasZZ.hyperp-dbaas.cloud.ibm.com:ZZZZ/admin?replicaSet=replicaSet1`\n\nNote, you will need to save the Username and Password when you create your instance as it will never be visible again. Add the user:pass to the URL above : `mongodb://user:pass@dbaasXX.` and store within the `.env` file as the `MONGO_DB` value. This connection url will be passed automatically to the typeorm createConnection api via env variable. The last necessary step is to download the DBaaS CA cert.pem file from the Cloud Dashboard, which must be saved in the src/ directory. \n\n```bash\n$ cat .env \nMONGO_DB=mongodb://admin:dbaasPassword123@dbaasXX.hyperp-dbaas.cloud.ibm.com:XXXX,dbaasYY.hyperp-dbaas.cloud.ibm.com:YYYY,dbaasZZ.hyperp-dbaas.cloud.ibm.com:ZZZZ/admin?replicaSet=Cluster_1_Example\n```\n\n**Note**: If an IBM DBaaS MongoDB connection string will **not** being used, simply set the `MONGO_DB` environmental variable to 'localhost' to utilize mongodb locally. \n\nNext, the `generate_certs.sh` shell script must be run, which will create all of the necessary SSL keys and certificates in order to build and run this application. One argument is required when running this script, and is dependent on what the  _Common Name_ value needs to be. \n\nTo run locally using `npm start` use: localhost\n\n**Note**: If building the application on a Virtual Server use the public IP address of the HPVS instance in lieu of the'localhost' argument.\n\n```bash\n$ sudo ./generate_certs.sh -c localhost\nPassword:\nGenerating RSA private key, 4096 bit long modulus\n..............................................................................++\n........................++\ne is 65537 (0x10001)\nGenerating RSA private key, 2048 bit long modulus\n............................................+++\n.....................................................+++\ne is 65537 (0x10001)\nSignature ok\nsubject=/C=US/ST=NC/O=IBM/CN=localhost\nGetting CA Private Key\n```\n\nNow that the certificates have been created, the `.env` file has been modified with the proper MongoDB connection string, we are ready to build and run the application. Run the _npm_ commands listed below to finish the build and run the application. \n\n**Prior** to running the _npm_ commands: If a DBaaS MongoDB connection string is **not** being used and 'localhost' was defined as the env variable , run the following command first:\n```bash\ndocker run -d -p 27017-27019:27017-27019 --name mongodb mongo\n```\n\n1. npm install\n2. npm start\n\nThe output will look similar to this:\n```bash\n$ npm  install\nnpm WARN hyper-protect-sdk-backend@0.0.1 No repository field.\nnpm WARN hyper-protect-sdk-backend@0.0.1 No license field.\n\naudited 735 packages in 1.835s\nfound 0 vulnerabilities\n\n$ npm start\n\n\u003e hyper-protect-sdk-backend@0.0.1 start /Users/dev/IBM-HyperProtectMBaaS\n\u003e set debug=* \u0026\u0026 ts-node-dev --respawn --transpileOnly ./src/index.ts\n\nUsing ts-node version 8.10.1, typescript version 3.8.3\n(node:34241) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.\nUUID : 9DB09908-F6CB-4FBC-B1B7-28BE697FAA96\nCareKit Backend SDK is running!\n```\n\u003cbr/\u003e\n\n**Validation**\n\nWe can validate that the app is running and configured correctly by simply running the predefined validation test, which uses the 'jest' npm package. If the test was run successfully the `npm start` window will have populated a new entry containing a `201` response. \n\nTo run the test, please use the `npm run test` command in a different terminal window (or tab) as depicted below. Please ensure that the directory in the recently opened terminal window/tab is pointed towards the locally cloned **IBM-HyperProtectMBaaS** repo.\n\n```bash\n$ npm run test\n\n\u003e ibm-hyperprotect-mbaas@0.0.1 test /Users/ryley.wharton1ibm.com/Documents/Github/IBM-HyperProtectMBaaS\n\u003e jest\n\n(node:13022) ExperimentalWarning: The fs.promises API is experimental\n PASS  __test__/BackendSDKValidationTest.spec.js\n  BackendSDK CareKit Function\n    ✓ Testing POST calls to Backend SDK (7 ms)\n\nTest Suites: 1 passed, 1 total\nTests:       1 passed, 1 total\nSnapshots:   0 total\nTime:        1.575 s\nRan all test suites.\n```\n\nIn the `npm start` window we should see a new line of text similar to: \n```bash\n::ffff:127.0.0.1 - POST /revisionRecord HTTP/1.1 201 21 - 197.409 ms\n```\n\n**The Backend SDK app is now running!**\n\n\n## For local-dev:\n\n- Docker\n- node.js\n- typescript\n\n`docker run -d -p 27017-27019:27017-27019 --name mongodb mongo`\n\nThe Swift-\u003eTypeScript data-structure converson was performed using: https://app.quicktype.io/. If any of the OCKxxx Classes/Structs/Enums/Protocols change, the changes will need to be reflected in the respective [entity][src/entity/*.ts] files. Out-of-sync structures will not lead to failure but to out-of-sync collection schema's between the iOS Core Data structures and the MongoDB backend. This can be tuned to fail instead.\n\n### Self-Paced Lab:\n\nDetailed end-to-end instructions for deploying the frontend ([IBM Hyper Protect SDK for CareKit](https://github.com/carekit-apple/IBM-HyperProtectSDK)) and the MBaaS (this project) with a CareKit sample app are provided [here](https://github.com/THINKLab2020/carekit-hyperprotect-lab).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarekit-apple%2Fibm-hyperprotectmbaas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarekit-apple%2Fibm-hyperprotectmbaas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarekit-apple%2Fibm-hyperprotectmbaas/lists"}