From f772d8a6d17b646945a5e44197a0d5d40c1efb96 Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Sun, 17 May 2020 14:04:35 +0200 Subject: [PATCH 01/35] docs(readme): fix badge --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f1e41551..3c64186c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@
-![Status](https://img.shields.io/badge/Status-developing-brightgree) [![Release](https://img.shields.io/github/release/HospitalRun/hospitalrun-server.svg)](https://github.com/HospitalRun/hospitalrun-server/releases) [![Version](https://img.shields.io/github/package-json/v/hospitalrun/hospitalrun-frontend)](https://github.com/HospitalRun/hospitalrun-server/releases) [![GitHub CI](https://github.com/HospitalRun/server/workflows/GitHub%20CI/badge.svg)](https://github.com/HospitalRun/server/actions) [![Coverage Status](https://coveralls.io/repos/github/HospitalRun/hospitalrun-server/badge.svg?branch=master)](https://coveralls.io/github/HospitalRun/hospitalrun-server?branch=master) [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/HospitalRun/hospitalrun-server.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/HospitalRun/hospitalrun-server/context:javascript) [![Documentation Status](https://readthedocs.org/projects/hospitalrun-server/badge/?version=latest)](https://hospitalrun-server.readthedocs.io) +![Status](https://img.shields.io/badge/Status-developing-brightgree) [![Release](https://img.shields.io/github/release/HospitalRun/hospitalrun-server.svg)](https://github.com/HospitalRun/hospitalrun-server/releases) [![Version](https://img.shields.io/github/package-json/v/hospitalrun/hospitalrun-server)](https://github.com/HospitalRun/hospitalrun-server/releases) [![GitHub CI](https://github.com/HospitalRun/server/workflows/GitHub%20CI/badge.svg)](https://github.com/HospitalRun/server/actions) [![Coverage Status](https://coveralls.io/repos/github/HospitalRun/hospitalrun-server/badge.svg?branch=master)](https://coveralls.io/github/HospitalRun/hospitalrun-server?branch=master) [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/HospitalRun/hospitalrun-server.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/HospitalRun/hospitalrun-server/context:javascript) [![Documentation Status](https://readthedocs.org/projects/hospitalrun-server/badge/?version=latest)](https://hospitalrun-server.readthedocs.io) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FHospitalRun%2Fhospitalrun-server.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FHospitalRun%2Fhospitalrun-server?ref=badge_shield) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) ![dependabot](https://api.dependabot.com/badges/status?host=github&repo=HospitalRun/hospitalrun-server) [![Slack](https://hospitalrun-slack.herokuapp.com/badge.svg)](https://hospitalrun-slack.herokuapp.com)
@@ -85,7 +85,7 @@ Read more at Date: Tue, 19 May 2020 18:53:33 +0200 Subject: [PATCH 02/35] build(deps-dev): bump @typescript-eslint/parser from 2.31.0 to 2.34.0 (#309) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 997445f6..ae57afac 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@types/node": "~13.13.2", "@types/qs": "6.9.1", "@typescript-eslint/eslint-plugin": "~2.30.0", - "@typescript-eslint/parser": "~2.31.0", + "@typescript-eslint/parser": "~2.34.0", "@types/require-from-string": "~1.2.0", "@types/sade": "~1.6.0", "chalk": "~4.0.0", From 363d8c75a675876bbf77d94d56fc61ae3ae47f72 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 19 May 2020 18:56:20 +0200 Subject: [PATCH 03/35] build(deps-dev): bump @typescript-eslint/eslint-plugin (#310) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ae57afac..e312955a 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@types/mkdirp": "~1.0.0", "@types/node": "~13.13.2", "@types/qs": "6.9.1", - "@typescript-eslint/eslint-plugin": "~2.30.0", + "@typescript-eslint/eslint-plugin": "~2.34.0", "@typescript-eslint/parser": "~2.34.0", "@types/require-from-string": "~1.2.0", "@types/sade": "~1.6.0", From 97aa9fee6244d31e49bb1a72ebcfdedf3d02cdfc Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 22 May 2020 10:35:55 +0200 Subject: [PATCH 04/35] build(deps-dev): bump @types/node from 13.13.9 to 14.0.5 (#313) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e312955a..44fad30d 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@commitlint/prompt": "~8.3.5", "@types/glob": "~7.1.1", "@types/mkdirp": "~1.0.0", - "@types/node": "~13.13.2", + "@types/node": "~14.0.5", "@types/qs": "6.9.1", "@typescript-eslint/eslint-plugin": "~2.34.0", "@typescript-eslint/parser": "~2.34.0", From 3b30f472645630a3d15cdd7635c12acc61ef181e Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Wed, 3 Jun 2020 11:27:35 +0200 Subject: [PATCH 05/35] docs(readme): update team --- README.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3c64186c..56f39efc 100644 --- a/README.md +++ b/README.md @@ -70,22 +70,32 @@ Read more at
Maksim Sinik](https://github.com/fox1t)
-## Core Team +## [Core Maintainers](https://github.com/orgs/HospitalRun/teams/core-maintainers) -| [
Stefano Casasola](https://github.com/irvelervel) |[
Michael Daly](https://github.com/MichaelDalyDev)|[
Riccardo Gulin](https://github.com/nclBaz) | [
Grace Lau](https://github.com/lauggh) | [
Jack Meyer](https://github.com/jackcmeyer) | [
Matteo Vivona](https://github.com/tehKapa) | -|---|---|---|---|---|---| +| [
Jack Meyer](https://github.com/jackcmeyer) | [
Matteo Vivona](https://github.com/tehKapa) | +|---|---| + +## [Core Contributors](https://github.com/orgs/HospitalRun/teams/core-contributor) + +| [
Stefano Casasola](https://github.com/irvelervel) | [
Kumiko Kashii](https://github.com/kumikokashii) | [
Grace Lau](https://github.com/lauggh) | [
Stefano Miceli](https://github.com/StefanoMiC) | +|---|---|---|---| ## Medical Supervisor [
M.D. Daniele Piccolo](https://it.linkedin.com/in/danielepiccolo)
+## Past Contributors + +[
Michael Daly](https://github.com/MichaelDalyDev)
+ ## Contributors -[![Contributors](https://opencollective.com/hospitalrun/contributors.svg?width=960&button=false)](https://github.com/HospitalRun/hospitalrun-server/graphs/contributors) +[![Contributors](https://opencollective.com/hospitalrun/contributors.svg?width=960&button=false)](https://github.com/HospitalRun/hospitalrun-frontend/graphs/contributors) ## Founders From 120f5ce5786558fc3de1271109845933e6f169b0 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 8 Jun 2020 16:45:34 +0200 Subject: [PATCH 06/35] build(deps-dev): bump @types/sade from 1.6.0 to 1.7.0 (#314) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 44fad30d..2b5fea40 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "@typescript-eslint/eslint-plugin": "~2.34.0", "@typescript-eslint/parser": "~2.34.0", "@types/require-from-string": "~1.2.0", - "@types/sade": "~1.6.0", + "@types/sade": "~1.7.0", "chalk": "~4.0.0", "commitizen": "~4.1.2", "commitlint-config-cz": "~0.13.0", From 0ad26768ef5477258e5e10590d838fcb1a1428fd Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 9 Jun 2020 18:23:30 +0200 Subject: [PATCH 07/35] build(deps-dev): bump chalk from 4.0.0 to 4.1.0 (#318) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b5fea40..4ecf7b07 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@typescript-eslint/parser": "~2.34.0", "@types/require-from-string": "~1.2.0", "@types/sade": "~1.7.0", - "chalk": "~4.0.0", + "chalk": "~4.1.0", "commitizen": "~4.1.2", "commitlint-config-cz": "~0.13.0", "cross-env": "~7.0.0", From 372fc9cf167584e5cbed342cd3692aac8ab4658b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 10 Jun 2020 14:20:30 +0200 Subject: [PATCH 08/35] build(deps-dev): bump eslint-plugin-import from 2.20.2 to 2.21.1 (#315) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4ecf7b07..c30980d7 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "dotenv": "~8.2.0", "eslint": "~6.8.0", "eslint-config-prettier": "~6.11.0", - "eslint-plugin-import": "~2.20.0", + "eslint-plugin-import": "~2.21.1", "eslint-plugin-prettier": "~3.1.0", "glob": "~7.1.6", "husky": "~4.2.0", From f3332fe56286fb72687cec3ef4d9c2a062aed26c Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Sun, 14 Jun 2020 10:03:47 +0200 Subject: [PATCH 09/35] chore(docs): remove yarn --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 56f39efc..942de4b5 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,8 @@ Contributions are always welcome. Before contributing please read our [contribut 1. [Fork](https://github.com/HospitalRun/hospitalrun-server/fork) this repository to your own GitHub account 2. Clone it to your local machine 3. Navigate to the cloned folder: `cd hospitalrun-server` -4. Install the dependencies: `npm install` or `yarn install` -5. Run `npm run dev` or `yarn dev` to build and watch for code changes: +4. Install the dependencies: `npm install` +5. Run `npm run dev` to build and watch for code changes: - a development database will start on http://localhost:5984 - you can access its Admin interface on http://localhost:5984/_utils, `username: dev` and `password: dev` @@ -32,16 +32,16 @@ In order to optimize the workflow and to prevent multiple contributors working o In order to run `hospitalrun-server` you need to set the correct environment variables. Since [dotenv](https://www.npmjs.com/package/dotenv) is already included, it is just matter of renaming `.env.example` file to `.env`: this file include all of the mandatory defaults. ## Development Database -This project uses [pouchdb-server](https://www.npmjs.com/package/pouchdb-server) for development and you, as contributor, don't need to provide your own CouchDB instance. Upon first run of the `dev` script (`npm run dev` or `yarn dev`), a new `data` folder will be created inside the `./db` folder. The database credentials are: `username: dev` and `password: dev`. The file `./db/config.json` contains the DB's configuration: you can change it if you want, but please don't commit any changes to it. +This project uses [pouchdb-server](https://www.npmjs.com/package/pouchdb-server) for development and you, as contributor, don't need to provide your own CouchDB instance. Upon first run of the `dev` script (`npm run dev`), a new `data` folder will be created inside the `./db` folder. The database credentials are: `username: dev` and `password: dev`. The file `./db/config.json` contains the DB's configuration: you can change it if you want, but please don't commit any changes to it. **Note: PouchDB-server is meant to be use only during development. Please don't deploy any production/testing HospitalRun instances on it. For production deployments please follow the deployment guide.** ## Tests -Every code additions or fixs on the existing code, has to be tested. This project uses [node-tap](https://node-tap.org/) as test runner. To run all tests use `npm run test` or `yarn test`. +Every code additions or fixs on the existing code, has to be tested. This project uses [node-tap](https://node-tap.org/) as test runner. To run all tests use `npm run test`. ## How to commit -This repo uses [Conventional Commits](https://www.conventionalcommits.org/). [Commitizen](https://github.com/commitizen/cz-cli) is mandatory for making proper commits. Once you have staged your changes, can run `npm run commit` or `yarn commit` from the root directory in order to commit following our standards. +This repo uses [Conventional Commits](https://www.conventionalcommits.org/). [Commitizen](https://github.com/commitizen/cz-cli) is mandatory for making proper commits. Once you have staged your changes, can run `npm run commit` from the root directory in order to commit following our standards. # Documentation ## DataBase From 3b5442cab445c4bbff4079a6143c6d39ca25dcb4 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 22 Jun 2020 14:51:51 +0000 Subject: [PATCH 10/35] build(deps): bump fastify from 2.14.1 to 2.15.0 Bumps [fastify](https://github.com/fastify/fastify) from 2.14.1 to 2.15.0. - [Release notes](https://github.com/fastify/fastify/releases) - [Commits](https://github.com/fastify/fastify/compare/v2.14.1...v2.15.0) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c30980d7..bbef8917 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "author": "Maksim Sinik ", "license": "MIT", "dependencies": { - "fastify": "~2.14.0", + "fastify": "~2.15.0", "fastify-autoload": "~1.2.2", "fastify-blipp": "~2.3.0", "fastify-cors": "~3.0.2", From 2850a84fbbe3e2236333a487c6e9b6b1dff9ea71 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 22 Jun 2020 14:59:30 +0000 Subject: [PATCH 11/35] build(deps-dev): bump @commitlint/config-conventional Bumps [@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint) from 8.3.4 to 9.0.1. - [Release notes](https://github.com/conventional-changelog/commitlint/releases) - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/CHANGELOG.md) - [Commits](https://github.com/conventional-changelog/commitlint/compare/v8.3.4...v9.0.1) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c30980d7..753a4c06 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ }, "devDependencies": { "@commitlint/cli": "~8.3.5", - "@commitlint/config-conventional": "~8.3.4", + "@commitlint/config-conventional": "~9.0.1", "@commitlint/prompt": "~8.3.5", "@types/glob": "~7.1.1", "@types/mkdirp": "~1.0.0", From 2ce6705d7057c3e8a8b9ccc142cc95ff2df388dc Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 27 Jun 2020 06:52:21 +0000 Subject: [PATCH 12/35] build(deps-dev): bump eslint-plugin-import from 2.21.2 to 2.22.0 Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.21.2 to 2.22.0. - [Release notes](https://github.com/benmosher/eslint-plugin-import/releases) - [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md) - [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.21.2...v2.22.0) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c30980d7..24c4e260 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "dotenv": "~8.2.0", "eslint": "~6.8.0", "eslint-config-prettier": "~6.11.0", - "eslint-plugin-import": "~2.21.1", + "eslint-plugin-import": "~2.22.0", "eslint-plugin-prettier": "~3.1.0", "glob": "~7.1.6", "husky": "~4.2.0", From 663df467fbf031d4b66f8f020f0d50275478a9d1 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 27 Jun 2020 17:57:30 +0200 Subject: [PATCH 13/35] build(deps-dev): bump @commitlint/prompt from 8.3.5 to 9.0.1 (#320) Bumps [@commitlint/prompt](https://github.com/conventional-changelog/commitlint) from 8.3.5 to 9.0.1. - [Release notes](https://github.com/conventional-changelog/commitlint/releases) - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/CHANGELOG.md) - [Commits](https://github.com/conventional-changelog/commitlint/compare/v8.3.5...v9.0.1) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: HospitalRun Bot Co-authored-by: Matteo Vivona --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fdf69c81..46d86eed 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "devDependencies": { "@commitlint/cli": "~8.3.5", "@commitlint/config-conventional": "~9.0.1", - "@commitlint/prompt": "~8.3.5", + "@commitlint/prompt": "~9.0.1", "@types/glob": "~7.1.1", "@types/mkdirp": "~1.0.0", "@types/node": "~14.0.5", From 24559a8231ff433314a42595d19a2e7678b50fa0 Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Wed, 1 Jul 2020 08:41:48 +0200 Subject: [PATCH 14/35] docs(readme): add more infos --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 942de4b5..f97ef7fc 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,8 @@ Contributions are always welcome. Before contributing please read our [contribut 2. Clone it to your local machine 3. Navigate to the cloned folder: `cd hospitalrun-server` 4. Install the dependencies: `npm install` -5. Run `npm run dev` to build and watch for code changes: +5. Check that [env variables](https://github.com/HospitalRun/hospitalrun-server#environment) are set correctly +6. Run `npm run dev` to build and watch for code changes: - a development database will start on http://localhost:5984 - you can access its Admin interface on http://localhost:5984/_utils, `username: dev` and `password: dev` From f34f9e4ed1f2f01b3c91e31750a341b696a1a600 Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Tue, 7 Jul 2020 19:51:12 +0200 Subject: [PATCH 15/35] ci(security): add codeql analysis --- .github/workflows/codeql-analysis.yml | 54 +++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..58839027 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,54 @@ +name: "Code scanning - action" + +on: + push: + branches: [master] + pull_request: + # The branches below must be a subset of the branches above + branches: [master] + schedule: + - cron: '0 6 * * 6' + +jobs: + CodeQL-Build: + + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.event_name == 'pull_request' }} + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + # Override language selection by uncommenting this and choosing your languages + # with: + # languages: go, javascript, csharp, python, cpp, java + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 From ce4ef19387c617104ed6d191dae63fad9ff3ccbe Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Tue, 7 Jul 2020 19:53:53 +0200 Subject: [PATCH 16/35] ci(security): update codeql analysis --- .github/workflows/codeql-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 58839027..8df05f7f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,4 +1,4 @@ -name: "Code scanning - action" +name: "Code scanning" on: push: From 9bbc5cdafcaf9c807e2593bea6a0e9738ebbd575 Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Tue, 7 Jul 2020 19:59:42 +0200 Subject: [PATCH 17/35] chore(readme): add new badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f97ef7fc..5f9fd5e2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@
-![Status](https://img.shields.io/badge/Status-developing-brightgree) [![Release](https://img.shields.io/github/release/HospitalRun/hospitalrun-server.svg)](https://github.com/HospitalRun/hospitalrun-server/releases) [![Version](https://img.shields.io/github/package-json/v/hospitalrun/hospitalrun-server)](https://github.com/HospitalRun/hospitalrun-server/releases) [![GitHub CI](https://github.com/HospitalRun/server/workflows/GitHub%20CI/badge.svg)](https://github.com/HospitalRun/server/actions) [![Coverage Status](https://coveralls.io/repos/github/HospitalRun/hospitalrun-server/badge.svg?branch=master)](https://coveralls.io/github/HospitalRun/hospitalrun-server?branch=master) [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/HospitalRun/hospitalrun-server.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/HospitalRun/hospitalrun-server/context:javascript) [![Documentation Status](https://readthedocs.org/projects/hospitalrun-server/badge/?version=latest)](https://hospitalrun-server.readthedocs.io) +![Status](https://img.shields.io/badge/Status-developing-brightgree) [![Release](https://img.shields.io/github/release/HospitalRun/hospitalrun-server.svg)](https://github.com/HospitalRun/hospitalrun-server/releases) [![Version](https://img.shields.io/github/package-json/v/hospitalrun/hospitalrun-server)](https://github.com/HospitalRun/hospitalrun-server/releases) [![GitHub CI](https://github.com/HospitalRun/server/workflows/GitHub%20CI/badge.svg)](https://github.com/HospitalRun/server/actions) [![Coverage Status](https://coveralls.io/repos/github/HospitalRun/hospitalrun-server/badge.svg?branch=master)](https://coveralls.io/github/HospitalRun/hospitalrun-server?branch=master) [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/HospitalRun/hospitalrun-server.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/HospitalRun/hospitalrun-server/context:javascript) ![Code scanning](https://github.com/HospitalRun/hospitalrun-server/workflows/Code%20scanning/badge.svg?branch=master) [![Documentation Status](https://readthedocs.org/projects/hospitalrun-server/badge/?version=latest)](https://hospitalrun-server.readthedocs.io) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FHospitalRun%2Fhospitalrun-server.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FHospitalRun%2Fhospitalrun-server?ref=badge_shield) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) ![dependabot](https://api.dependabot.com/badges/status?host=github&repo=HospitalRun/hospitalrun-server) [![Slack](https://hospitalrun-slack.herokuapp.com/badge.svg)](https://hospitalrun-slack.herokuapp.com)
From 755b80f20260d9644e9bad15b6b649a576734fd4 Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Thu, 9 Jul 2020 12:47:08 +0200 Subject: [PATCH 18/35] chore(issue): update security issue template --- .github/ISSUE_TEMPLATE/security.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/security.md b/.github/ISSUE_TEMPLATE/security.md index 220fccc7..76ca873d 100644 --- a/.github/ISSUE_TEMPLATE/security.md +++ b/.github/ISSUE_TEMPLATE/security.md @@ -1,6 +1,8 @@ --- name: 👮 Security Issue about: Responsible Disclosure +labels: 'security' + --- ## 👮 [Responsible Disclosure](https://github.com/nodejs/security-wg/blob/master/processes/responsible_disclosure_template.md) @@ -8,4 +10,4 @@ about: Responsible Disclosure Do not open issues that might have security implications. It is critical that security related issues are reported privately so we have time to address them before they become public knowledge. -Vulnerabilities can also be reported by emailing security@hospitalrun.io +Vulnerabilities can also be reported by emailing security@hospitalrun.io From f58954a5348c602bfa97d457c639a8ecc5599207 Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Thu, 9 Jul 2020 12:48:54 +0200 Subject: [PATCH 19/35] chore(security): add responsible disclosure policy --- SECURITY.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..798ae845 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,21 @@ +# Responsible Disclosure Policy + +A responsible disclosure policy helps protect the project and its users from security vulnerabilities discovered in the project’s scope by employing a process where vulnerabilities are publicly disclosed after a reasonable time period to allow patching the vulnerability. + +All security bugs are taken seriously and are considered as top priority. +Your efforts to responsibly disclose your findings are appreciated and will be taken into account to acknowledge your contributions. + +## Supported Versions + +This versions of HospitalRun project are currently being supported with security updates. + +| Version | Supported | +| ------- | ------------------ | +| 2.0.0 | :white_check_mark: | +| 1.0.0-beta | :x: | + +## Reporting a Vulnerability + +Report security bugs by opening a new [Security Issue](https://github.com/HospitalRun/hospitalrun-server/issues/new?template=security.md). You can also report a vulnerability by emailing security@hospitalrun.io. + +Report security bugs in third-party modules to the maintainer or team maintaining the module. From a09c08cdcc81ec003c3debda7dba9d31b184fb1c Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2020 03:57:11 +0000 Subject: [PATCH 20/35] build(deps-dev): bump @commitlint/config-conventional Bumps [@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint) from 9.0.1 to 9.1.1. - [Release notes](https://github.com/conventional-changelog/commitlint/releases) - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/CHANGELOG.md) - [Commits](https://github.com/conventional-changelog/commitlint/compare/v9.0.1...v9.1.1) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 46d86eed..cf9dbc49 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ }, "devDependencies": { "@commitlint/cli": "~8.3.5", - "@commitlint/config-conventional": "~9.0.1", + "@commitlint/config-conventional": "~9.1.1", "@commitlint/prompt": "~9.0.1", "@types/glob": "~7.1.1", "@types/mkdirp": "~1.0.0", From 44bbba3d733f279d7510b5ba6103c72c82844ead Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2020 04:08:03 +0000 Subject: [PATCH 21/35] build(deps-dev): bump @commitlint/prompt from 9.0.1 to 9.1.1 Bumps [@commitlint/prompt](https://github.com/conventional-changelog/commitlint) from 9.0.1 to 9.1.1. - [Release notes](https://github.com/conventional-changelog/commitlint/releases) - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/CHANGELOG.md) - [Commits](https://github.com/conventional-changelog/commitlint/compare/v9.0.1...v9.1.1) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 46d86eed..512930de 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "devDependencies": { "@commitlint/cli": "~8.3.5", "@commitlint/config-conventional": "~9.0.1", - "@commitlint/prompt": "~9.0.1", + "@commitlint/prompt": "~9.1.1", "@types/glob": "~7.1.1", "@types/mkdirp": "~1.0.0", "@types/node": "~14.0.5", From 1f12a71657cdb6452de453831c447d58ab46222b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 20 Jul 2020 14:09:23 +0000 Subject: [PATCH 22/35] build(deps): bump fastify-blipp from 2.3.1 to 3.0.0 Bumps [fastify-blipp](https://github.com/PavelPolyakov/fastify-blipp) from 2.3.1 to 3.0.0. - [Release notes](https://github.com/PavelPolyakov/fastify-blipp/releases) - [Changelog](https://github.com/PavelPolyakov/fastify-blipp/blob/master/CHANGELOG.md) - [Commits](https://github.com/PavelPolyakov/fastify-blipp/commits) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 512930de..88ad6130 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "dependencies": { "fastify": "~2.15.0", "fastify-autoload": "~1.2.2", - "fastify-blipp": "~2.3.0", + "fastify-blipp": "~3.0.0", "fastify-cors": "~3.0.2", "fastify-helmet": "~3.0.2", "fastify-http-proxy": "~3.1.0", From da17adfd1d40d7cefc01b9013f776620f905b833 Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Tue, 4 Aug 2020 13:00:29 +0200 Subject: [PATCH 23/35] chore(readme): remove chapter behind hospitalrun --- README.md | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) diff --git a/README.md b/README.md index 5f9fd5e2..fcf71fc2 100644 --- a/README.md +++ b/README.md @@ -54,56 +54,6 @@ Read more at
HospitalRun Services. -
- -# Behind HospitalRun - -## Hosted by - -[](https://openjsf.org/projects/#atlarge) - -## Sponsors - -[![Sponsors](https://opencollective.com/hospitalrun/sponsors.svg?width=890)](https://opencollective.com/hospitalrun/contribute/sponsors-336/checkout) - -## Backers - -[![Backers](https://opencollective.com/hospitalrun/backers.svg?width=890)](https://opencollective.com/hospitalrun/contribute/backers-335/checkout) - -## Lead Maintainer - -[
Maksim Sinik](https://github.com/fox1t)
- -## [Core Maintainers](https://github.com/orgs/HospitalRun/teams/core-maintainers) - - -| [
Jack Meyer](https://github.com/jackcmeyer) | [
Matteo Vivona](https://github.com/tehKapa) | -|---|---| - -## [Core Contributors](https://github.com/orgs/HospitalRun/teams/core-contributor) - - -| [
Stefano Casasola](https://github.com/irvelervel) | [
Kumiko Kashii](https://github.com/kumikokashii) | [
Grace Lau](https://github.com/lauggh) | [
Stefano Miceli](https://github.com/StefanoMiC) | -|---|---|---|---| - -## Medical Supervisor - -[
M.D. Daniele Piccolo](https://it.linkedin.com/in/danielepiccolo)
- -## Past Contributors - -[
Michael Daly](https://github.com/MichaelDalyDev)
- -## Contributors - -[![Contributors](https://opencollective.com/hospitalrun/contributors.svg?width=960&button=false)](https://github.com/HospitalRun/hospitalrun-frontend/graphs/contributors) - -## Founders - - -| [
John Kleinschmidtr](https://github.com/jkleinsc) | [
Joel Worrall](https://github.com/tangollama) | [
Joel Glovier](https://github.com/jglovier) | -|---|---|---| - # License Released under the [MIT license](LICENSE). From beb7cb9fab9768dab431ccf7bab6bc4dc89486c0 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 11 Aug 2020 22:28:31 +0000 Subject: [PATCH 24/35] build(deps-dev): bump pino-colada from 2.0.1 to 2.1.0 Bumps [pino-colada](https://github.com/lrlna/pino-colada) from 2.0.1 to 2.1.0. - [Release notes](https://github.com/lrlna/pino-colada/releases) - [Commits](https://github.com/lrlna/pino-colada/compare/v2.0.1...v2.1.0) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 642f9585..88fc7960 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "mkdirp": "~1.0.3", "nodemon": "~2.0.0", "npm-run-all": "~4.1.5", - "pino-colada": "~2.0.0", + "pino-colada": "~2.1.0", "pouchdb-server": "~4.2.0", "prettier": "~2.0.2", "rimraf": "~3.0.0", From aef922632b5565c569ca3cd48092e1509bd9ebab Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Wed, 12 Aug 2020 09:30:58 +0200 Subject: [PATCH 25/35] ci(github): readd node 10 --- .github/workflows/ci.yml | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 10095473..558acd59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - node-version: [12.x] + node-version: [10.x, 12.x, 14.x] os: [ubuntu-latest, windows-latest, macOS-latest] # exclude: # - os: windows-latest @@ -36,35 +36,3 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: ./lcov.info - - yarn: - runs-on: ${{ matrix.os }} - strategy: - matrix: - node-version: [12.x] - os: [ubuntu-latest, windows-latest, macOS-latest] - # exclude: - # - os: windows-latest - # node-version: 13.x - steps: - - run: git config --global core.autocrlf false # this is needed to prevent git changing EOL after cloning on Windows OS - - uses: actions/checkout@v2 - - name: Use Node.js - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: Init yarn - run: | - npm install -g yarn - - name: Install with yarn - run: | - yarn install - - name: Lint code - run: | - yarn lint - - name: Build - run: | - yarn build:all - - name: Run tests - run: | - yarn test From ff735b437fe3bd47a14acc0741aa81863b82c395 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 17 Aug 2020 15:13:18 +0000 Subject: [PATCH 26/35] build(deps-dev): bump @types/node from 14.0.27 to 14.6.0 Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.0.27 to 14.6.0. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 88fc7960..d3dcca59 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@commitlint/prompt": "~9.1.1", "@types/glob": "~7.1.1", "@types/mkdirp": "~1.0.0", - "@types/node": "~14.0.5", + "@types/node": "~14.6.0", "@types/qs": "6.9.1", "@typescript-eslint/eslint-plugin": "~2.34.0", "@typescript-eslint/parser": "~2.34.0", From e5804e167ae2ea2d5b0c17d3b644264b779291e7 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 26 Aug 2020 06:36:04 +0000 Subject: [PATCH 27/35] build(deps-dev): bump commitizen from 4.1.5 to 4.2.1 Bumps [commitizen](https://github.com/commitizen/cz-cli) from 4.1.5 to 4.2.1. - [Release notes](https://github.com/commitizen/cz-cli/releases) - [Commits](https://github.com/commitizen/cz-cli/compare/v4.1.5...v4.2.1) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d3dcca59..6475c49c 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@types/require-from-string": "~1.2.0", "@types/sade": "~1.7.0", "chalk": "~4.1.0", - "commitizen": "~4.1.2", + "commitizen": "~4.2.1", "commitlint-config-cz": "~0.13.0", "cross-env": "~7.0.0", "cz-conventional-changelog": "~3.2.0", From 9ce564f1ee606553f30b669142b3bdc0c7d63fdc Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 30 Aug 2020 13:16:40 +0000 Subject: [PATCH 28/35] build(deps-dev): bump @commitlint/cli from 8.3.5 to 9.1.2 Bumps [@commitlint/cli](https://github.com/conventional-changelog/commitlint) from 8.3.5 to 9.1.2. - [Release notes](https://github.com/conventional-changelog/commitlint/releases) - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/CHANGELOG.md) - [Commits](https://github.com/conventional-changelog/commitlint/compare/v8.3.5...v9.1.2) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6475c49c..539405f3 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "require-from-string": "~2.0.2" }, "devDependencies": { - "@commitlint/cli": "~8.3.5", + "@commitlint/cli": "~9.1.2", "@commitlint/config-conventional": "~9.1.1", "@commitlint/prompt": "~9.1.1", "@types/glob": "~7.1.1", From 53c48d68bf30b41ca7926cc7a5e19495442d022a Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Sun, 30 Aug 2020 09:58:34 -0500 Subject: [PATCH 29/35] refactor(couchdb): remove couchdb related code --- .env.example | 1 - .eslintrc.js | 2 +- .gitignore | 1 + package.json | 12 +- src/bin/ddoc.ts | 121 ----------------- src/db/design-document.ts | 123 ----------------- src/db/design-functions-context.d.ts | 195 --------------------------- src/db/tsconfig.json | 16 --- src/index.ts | 3 - src/plugins/couchdb/index.ts | 30 ----- src/plugins/couchdb/proxy.ts | 24 ---- 11 files changed, 6 insertions(+), 522 deletions(-) delete mode 100644 src/bin/ddoc.ts delete mode 100644 src/db/design-document.ts delete mode 100644 src/db/design-functions-context.d.ts delete mode 100644 src/db/tsconfig.json delete mode 100644 src/plugins/couchdb/index.ts delete mode 100644 src/plugins/couchdb/proxy.ts diff --git a/.env.example b/.env.example index 8e19eccf..e69de29b 100644 --- a/.env.example +++ b/.env.example @@ -1 +0,0 @@ -COUCHDB_URL="http://localhost:5984" diff --git a/.eslintrc.js b/.eslintrc.js index 0b15c56e..dd47d317 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,7 +8,7 @@ module.exports = { ], parser: '@typescript-eslint/parser', parserOptions: { - project: ['./tsconfig.json', './test/tsconfig.json', './src/db/tsconfig.json'], + project: ['./tsconfig.json', './test/tsconfig.json'], tsconfigRootDir: './', }, plugins: ['@typescript-eslint', 'prettier'], diff --git a/.gitignore b/.gitignore index 14bc0e75..71eb1634 100644 --- a/.gitignore +++ b/.gitignore @@ -63,3 +63,4 @@ db/* !db/config.json !db/designs .env +.idea/ diff --git a/package.json b/package.json index 6475c49c..ee405d39 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@hospitalrun/server", "version": "2.0.0-alpha.2", - "description": "HospitalRun Nodejs server", + "description": "HospitalRun Node.js server", "main": "dist", "repository": { "type": "git", @@ -11,16 +11,13 @@ "ddoc": "node bin/ddoc", "commit": "npx git-cz", "build": "npm run clean && tsc -p ./tsconfig.json", - "build:all": "run-s build build:ddoc build:designs", - "build:ddoc": "rimraf bin && tsc -p ./src/bin/tsconfig.json", - "build:designs": "npm run ddoc -- src/db/designs -c src/db/tsconfig.json", + "build:all": "run-s build", "start": "node dist", "clean": "rimraf dist", - "dev:db": "pouchdb-server --config ./db/config.json", - "dev:build": "tsc --incremental -p tsconfig.json && npm run build:designs", + "dev:build": "tsc --incremental -p tsconfig.json", "dev:start": "node --inspect -r source-map-support/register -r dotenv/config dist/index.js | pino-colada", "dev:watch": "cross-env NODE_ENV=development npm run clean && nodemon -w src -e ts --exec \"npm run dev:build && npm run dev:start\"", - "dev": "run-p dev:db dev:watch", + "dev": "run-p dev:watch", "update": "yarn upgrade-interactive --latest", "lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"test/**/*.{js,jsx,ts,tsx}\"", "lint:fix": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"test/**/*.{js,jsx,ts,tsx}\" --fix", @@ -75,7 +72,6 @@ "nodemon": "~2.0.0", "npm-run-all": "~4.1.5", "pino-colada": "~2.1.0", - "pouchdb-server": "~4.2.0", "prettier": "~2.0.2", "rimraf": "~3.0.0", "sade": "~1.7.3", diff --git a/src/bin/ddoc.ts b/src/bin/ddoc.ts deleted file mode 100644 index 9b75c229..00000000 --- a/src/bin/ddoc.ts +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env node - -import path from 'path' -import fs from 'fs' -import { promisify } from 'util' -import sade from 'sade' -import ts from 'typescript' -import requireFromString from 'require-from-string' -import originalGlob from 'glob' -import mkdirp from 'mkdirp' -import chalk from 'chalk' - -const stat = promisify(fs.stat) -const readFile = promisify(fs.readFile) -const writeFile = promisify(fs.writeFile) -const unlink = promisify(fs.unlink) -const glob = promisify(originalGlob) - -async function deleteOldDdocs(dest: string) { - const oldDdocs = await glob(path.join(dest, '**/*.json')) - return Promise.all(oldDdocs.map(file => unlink(file))) -} - -const prog = sade('ddoc') - -prog.version('0.1.0') - -prog - .command('build ', 'Build design document(s) from TypeScript soruce directory or file.', { - default: true, - }) - // .describe('Build design documents from TypeScript soruce directory or file.') - .option('-c, --config', 'Provide path to custom tsconfig.json', './tsconfig.json') - .example('build src/db/designs') - .example('build src/db/designs/patient.ts -c src/db/tsconfig.json') - .action(async (src, opts) => { - try { - const cwd = process.cwd() - const tsconfigPath = path.isAbsolute(opts.config) ? opts.config : path.join(cwd, opts.config) - - console.log( - `> ${chalk.bgBlueBright(chalk.black(' ddoc build config '))} ${chalk.cyan(tsconfigPath)}`, - ) - const tsconfig = require(tsconfigPath) // eslint-disable-line - - src = path.isAbsolute(src) ? path.normalize(src) : path.join(cwd, src) // eslint-disable-line - let srcStats: any - try { - srcStats = await stat(src) - } catch (err) { - if (err.code === 'ENOENT') { - console.log(chalk.bgGreen(chalk.black(`\n ddoc build - No input files found. Done. `))) - process.exit(0) - } - throw err - } - // use outDir if specified inside tsconfig, otherwise build json alongside ts files - let dest: string = tsconfig?.compilerOptions?.outDir - ? path.join(path.dirname(tsconfigPath), tsconfig.compilerOptions.outDir) - : '' - let ddocs: string[] - if (srcStats.isDirectory()) { - dest = dest || src - ddocs = await glob(path.join(src, '**/*.ts')) - } else { - dest = dest || path.dirname(src) - ddocs = [src] - } - - console.log(`> ${chalk.bgBlueBright(chalk.black(' ddoc build src '))} ${chalk.cyan(src)}`) - await mkdirp(dest) - await deleteOldDdocs(dest) - console.log(`> ${chalk.bgBlueBright(chalk.black(' ddoc build dest '))} ${chalk.cyan(dest)}`) - - const errors: { file: string; error: Error }[] = [] - await Promise.all( - ddocs.map(async srcPath => { - try { - const sourceFile = (await readFile(srcPath)).toString() - const output = ts.transpileModule(sourceFile, tsconfig) - const filename = path.basename(srcPath, '.ts') - const ddoc = requireFromString(output.outputText) - - const stringifiedDesign = JSON.stringify( - ddoc.default ?? ddoc, - (_, val) => { - if (typeof val === 'function') { - return val.toString() - } - return val - }, - 1, - ) - await writeFile(path.join(dest, `${filename}.json`), stringifiedDesign) - } catch (error) { - errors.push({ file: srcPath, error }) - } - }), - ) - if (errors.length > 0) { - errors.forEach(err => { - console.log( - `\n> ${chalk.bgRed(chalk.white(' ddoc build compile error '))} ${chalk.cyan( - err.file, - )}${err.error.stack?.toString()}\n`, - ) - }) - throw new Error( - `ddoc compilation failed. Resolve errors ${errors.length} ${ - errors.length > 1 ? 'files' : 'file' - } and try again.`, - ) - } - console.log(chalk.bgGreen(chalk.black(`\n ddoc build - done on ${ddocs.length} files. `))) - } catch (err) { - console.error(chalk.bgRed(chalk.white(` ${err.message} `))) - process.exit(1) - } - }) - -prog.parse(process.argv) diff --git a/src/db/design-document.ts b/src/db/design-document.ts deleted file mode 100644 index 0da8afd6..00000000 --- a/src/db/design-document.ts +++ /dev/null @@ -1,123 +0,0 @@ -// Reference: https://docs.couchdb.org/en/latest/ddocs/ddocs.html and https://docs.couchdb.org/en/latest/api/ddoc/common.html#put--db-_design-ddoc -interface DesignDocument { - _id: string - _rev?: string - language?: string // defaults to 'javascript' - autoupdate?: boolean // defaults to 'true' - // Reference: https://docs.couchdb.org/en/stable/api/ddoc/views.html#view-options - options?: { - local_seq?: boolean - include_design?: boolean - } - views?: { - [key: string]: { - /** - * Map functions accept a single document as the argument and (optionally) emit() key/value pairs that are stored in a view. - * Since version 1.1.0, map supports CommonJS modules and the require() function. - * - * Reference: https://docs.couchdb.org/en/master/ddocs/ddocs.html#map-functions - * @param {Object} doc - The document that is being processed - * @returns {void} - */ - map?(doc: T): void - /** - * Reduce functions take two required arguments of keys and values lists - the result of the related map function - and an optional third value which indicates if rereduce mode is active or not. - * Rereduce is used for additional reduce values list, so when it is true there is no information about related keys (first argument is null). - * - * Reference: https://docs.couchdb.org/en/master/ddocs/ddocs.html#reduce-and-rereduce-functions - * @param {[string, string][] | null} keys - Array of pairs of docid-key for related map function results. Always null if rereduce is running (has true value). - * @returns {Object} - */ - reduce?(keys: [string, string][] | null, values: any[], rereduce?: boolean): any - } - } - updates?: { - /** - * Update handlers are functions that clients can request to invoke server-side logic that will create or update a document. - * This feature allows a range of use cases such as providing a server-side last modified timestamp, - * updating individual fields in a document without first getting the latest revision, etc. - * - * Reference: https://docs.couchdb.org/en/master/ddocs/ddocs.html#update-functions - * @param {Object | null} doc - Thedocument that is being processed - * @param {Object} req - Request object - * @returns {[Object, any]} - the first element is the (updated or new) document, which is committed to the database; The second element is the response that will be sent back to the caller. - */ - [key: string]:

( - doc: P, - req: CouchDB.RequestObject, - ) => [Partial | null, any] - } - filters?: { - /** - * Filter functions mostly act like Show Functions and List Functions: they format, or filter the changes feed. - * - * Reference: https://docs.couchdb.org/en/master/ddocs/ddocs.html#filter-functions - * @param {Object} doc - The document that is being processed - * @param {Object} req - Request object - * @returns {boolean} - true means that doc passes the filter rules, false means that it does not - */ - [key: string]: (doc: T, req: CouchDB.RequestObject) => boolean - } - /** - * Used to prevent invalid or unauthorized document update requests from being stored. - * The function is passed the new document from the update request, the current document stored in the database, - * a User Context Object containing information about the user writing the document (if present), - * and a Security Object with lists of database security roles. - * - * Reference: https://docs.couchdb.org/en/master/ddocs/ddocs.html#validatefun - * @param {Object} newDoc - New version of document that will be stored - * @param {Object} oldDoc - Previous version of document that is already stored - * @param {Object} userCtx - User Context Object - * @param {Object} secObj - Security Object - * @returns {void} - */ - // - validate_doc_update?( // eslint-disable-line - newDoc: T, - oldDoc: T, - userCtx: CouchDB.UserCtx, - secObj: CouchDB.SecurityObject, - ): void - /** - * @deprecated in CouchDB 3.0, and will be removed in CouchDB 4.0 - */ - shows?: { - /** - * @deprecated in CouchDB 3.0, and will be removed in CouchDB 4.0 - * Show functions are used to represent documents in various formats, commonly as HTML pages with nice formatting. - * They can also be used to run server-side functions without requiring a pre-existing document. - * - * Reference: https://docs.couchdb.org/en/master/ddocs/ddocs.html#show-functions - * @param {Object} doc - The document that is being processed; may be omitted - * @param {Object} req - Request object - * @returns {Object | string} - */ - [key: string]: (doc: T, req: CouchDB.RequestObject) => string | CouchDB.ResponseObject | void - } - /** - * @deprecated in CouchDB 3.0, and will be removed in CouchDB 4.0 - */ - lists?: { - /** - * @deprecated in CouchDB 3.0, and will be removed in CouchDB 4.0 - * While Show Functions are used to customize document presentation, - * List Functions are used for the same purpose, but on View Functions results. - * - * Reference: https://docs.couchdb.org/en/master/ddocs/ddocs.html#list-functions - * @param {Object} head - View Head Information - * @param {Object} req - Request object - * @returns {string} Last chunk - */ - [key: string]: (head: CouchDB.ViewHeadInformation, req: CouchDB.RequestObject) => string | void - } - /** - * @deprecated in CouchDB 3.0, and will be removed in CouchDB 4.0 - * Rewrites the specified path by rules defined in the specified design document. - * The rewrite rules are defined by the rewrites field of the design document. - * The rewrites field can either be a string containing the a rewrite function or an array of rule definitions. - * - */ - rewrites?: ((req: CouchDB.Request2Object) => CouchDB.RewriteReturnObject) | CouchDB.RewriteRule[] -} - -export default DesignDocument diff --git a/src/db/design-functions-context.d.ts b/src/db/design-functions-context.d.ts deleted file mode 100644 index e5c447a6..00000000 --- a/src/db/design-functions-context.d.ts +++ /dev/null @@ -1,195 +0,0 @@ -// Reference: https://docs.couchdb.org/en/latest/query-server/javascript.html#design-functions-context - -declare namespace CouchDB { - type HttpMethods = 'HEAD' | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'OPTIONS' | 'TRACE' - interface InitResp { - code?: number - json?: object - body?: string - base64?: string - headers?: any - stop?: boolean - } - - interface UserCtx { - db: string - name: string | null - roles: string[] - } - - interface SecurityObject { - admins: { - names: string[] - roles: string[] - } - members: { - names: string[] - roles: string[] - } - } - - interface DataBaseInformationObject { - db_name: string - committed_update_seq: number - doc_count: number - doc_del_count: number - compact_running: boolean - disk_format_version: number - disk_size: number - instance_start_time: string - purge_seq: number - update_seq: number - sizes: { - active: number - disk: number - external: number - } - } - - interface RequestObject { - body: string - cookie: unknown - form: unknown - headers: unknown - id: string | null - info: CouchDB.DataBaseInformationObject - method: HttpMethods - path: string[] - peer: string - query: unknown - raw_path: string - requested_path: string[] - secObj: CouchDB.SecurityObject - userCtx: CouchDB.UserCtx - uuid: string - } - - interface RewriteRule { - method?: string - from: string - to: string - query: unknown - } - - interface Request2Object { - body: string - cookie: unknown - headers: unknown - method: HttpMethods - path: string[] - peer: string - query: unknown - requested_path: string[] - raw_path: string - secObj: CouchDB.SecurityObject - userCtx: CouchDB.UserCtx - } - - interface RewriteReturnObject { - path: string - code?: number - query?: unknown - headers?: any - method?: HttpMethods - body?: string - } - - interface ResponseObject { - code?: number - json?: any - body?: string - base64?: string - headers?: any - stop?: boolean - } - - interface ViewHeadInformation { - total_rows: number - offset: number - } -} - -/** - * Emits a key-value pair for further processing by CouchDB after the map function is done. - * @param {string} key - The view key - * @param {any} value - The key’s associated value - * @returns {void} - */ -declare function emit(key: string, value: any): void -/** - * @deprecated since version 2.0 - * Extracts the next row from a related view result. - * @returns {Object} - View result row - */ -declare function getRow(): T - -/** - * A helper function to check if the provided value is an Array. - * @param {Object} obj - Any JavaScript value - * @returns {boolean} - */ -declare function isArray(obj: T): boolean - -/** - * Log a message to the CouchDB log (at the INFO level). - * @param {string} message - Message to be logged - * @returns {void} - */ -declare function log(message: string): void - -/** - * @deprecated since version 2.0 - * Registers callable handler for specified MIME key. - * @param {string} key - MIME key previously defined by registerType() - * @param {Function} value - MIME type handler - * @returns {void} - */ -declare function provides(key: string, func: Function): string | CouchDB.ResponseObject - -/** - * @deprecated since version 2.0 - * Registers list of MIME types by associated key. - * @param {string} key - MIME types - * @param {string[]} mimes - MMIME types enumeration - * @returns {void} - */ -declare function registerType(key: string, mimes: string[]): void - -/** - * @deprecated since version 2.0 - * Sends a single string chunk in response. - * @param {string} chunk - Text chunk - * @returns {void} - */ -declare function send(chunk: string): void - -/** - * @deprecated since version 2.0 - * Initiates chunked response. As an option, a custom response object may be sent at this point. For list-functions only! - * @param {Object} init_resp - InitResp object - * @returns {void} - */ -// eslint-disable-next-line -declare function start(init_resp?: CouchDB.InitResp): void - -/** - * Sum arr’s items. - * @param {number[]} arr - Array of numbers - * @returns {number} - */ -declare function sum(arr: number[]): number - -/** - * Encodes obj to JSON string. This is an alias for the JSON.stringify method. - * @param {any} obj - Array of numbers - * @returns {string} - */ -declare function toJSON(obj: any): string - -/** - * Reduce functions take two required arguments of keys and values lists - the result of the related map function - and an optional third value which indicates if rereduce mode is active or not. - * Rereduce is used for additional reduce values list, so when it is true there is no information about related keys (first argument is null). - * @param {string[] | null} keys - Array of pairs of docid-key for related map function results. Always null if rereduce is running (has true value). - * @returns {void} - */ -declare type redfun = (keys: [string, string][] | null, values: any[], rereduce?: boolean) => any diff --git a/src/db/tsconfig.json b/src/db/tsconfig.json deleted file mode 100644 index 65c19345..00000000 --- a/src/db/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": [ - "." - ], - "exclude": [ - "node_modules" - ], - "compilerOptions": { - "typeRoots": [ - "./design-functions-context.d.ts" - ], - "outDir": "../../db/designs", - "sourceMap": false - } -} diff --git a/src/index.ts b/src/index.ts index 478b365b..8ddd38ac 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,8 +22,5 @@ fastify.listen(port, ip, err => { } if (process.env.NODE_ENV !== 'production') { fastify.blipp() - fastify.log.info( - `Database username 'dev', password 'dev, GUI running on: http://localhost:5984/_utils`, - ) } }) diff --git a/src/plugins/couchdb/index.ts b/src/plugins/couchdb/index.ts deleted file mode 100644 index 6491347a..00000000 --- a/src/plugins/couchdb/index.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { FastifyInstance, FastifyError } from 'fastify' -import fp from 'fastify-plugin' -import nano, { ServerScope, Configuration } from 'nano' -import proxy from './proxy' - -const COUCHDB_URL = process.env.COUCHDB_URL ? String(process.env.COUCHDB_URL) : undefined - -function couchDB( - fastify: FastifyInstance, - options: Configuration, - next: (err?: FastifyError | undefined) => void, -) { - const url = COUCHDB_URL || options.url - const couch = nano({ ...options, url }) - fastify.decorate('couch', couch) - fastify.register(proxy, { url }) - next() -} - -couchDB.autoConfig = { - url: COUCHDB_URL, -} - -export default fp(couchDB) - -declare module 'fastify' { - interface FastifyInstance { - couch: ServerScope - } -} diff --git a/src/plugins/couchdb/proxy.ts b/src/plugins/couchdb/proxy.ts deleted file mode 100644 index c34738ed..00000000 --- a/src/plugins/couchdb/proxy.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { FastifyInstance, FastifyError } from 'fastify' -import proxy from 'fastify-http-proxy' - -interface Options { - url: string -} - -function couchDBProxy( - fastify: FastifyInstance, - options: Options, - next: (err?: FastifyError | undefined) => void, -) { - fastify.register(proxy, { - upstream: options.url, - prefix: '/_db', - }) - next() -} - -couchDBProxy.autoConfig = { - url: process.env.COUCHDB_URL, -} - -export default couchDBProxy From 201cf567f9090c644ce2dd81e638024a8e4a0ce3 Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Mon, 31 Aug 2020 00:19:08 -0500 Subject: [PATCH 30/35] refactor(grahql): working example with gql --- package.json | 27 +++++------ src/app.ts | 48 +++++++------------ src/graphql/resolvers.ts | 7 +++ src/graphql/schema.ts | 7 +++ src/index.ts | 23 ++++----- src/plugins/support.ts | 14 ------ src/services/health.ts | 13 +++++ src/services/root.ts | 11 +++-- test/helper.ts | 2 +- test/plugins/support.test.ts | 11 ----- .../services/{root.test.ts => health.test.ts} | 6 +-- typings/fastify-blipp/index.d.ts | 7 --- typings/fastify-no-icon/index.d.ts | 7 --- typings/fastify/index.d.ts | 6 --- typings/tap/index.d.ts | 5 -- 15 files changed, 75 insertions(+), 119 deletions(-) create mode 100644 src/graphql/resolvers.ts create mode 100644 src/graphql/schema.ts delete mode 100644 src/plugins/support.ts create mode 100644 src/services/health.ts delete mode 100644 test/plugins/support.test.ts rename test/services/{root.test.ts => health.test.ts} (52%) delete mode 100644 typings/fastify-blipp/index.d.ts delete mode 100644 typings/fastify-no-icon/index.d.ts delete mode 100644 typings/fastify/index.d.ts delete mode 100644 typings/tap/index.d.ts diff --git a/package.json b/package.json index ee405d39..e54e2828 100644 --- a/package.json +++ b/package.json @@ -30,18 +30,15 @@ "author": "Maksim Sinik ", "license": "MIT", "dependencies": { - "fastify": "~2.15.0", - "fastify-autoload": "~1.2.2", + "fastify": "~3.3.0", + "fastify-autoload": "~3.0.8", "fastify-blipp": "~3.0.0", - "fastify-cors": "~3.0.2", - "fastify-helmet": "~3.0.2", - "fastify-http-proxy": "~3.1.0", - "fastify-no-icon": "~3.0.0", - "fastify-plugin": "~1.6.1", - "make-promises-safe": "~5.1.0", - "nano": "~8.2.1", - "qs": "~6.9.1", - "require-from-string": "~2.0.2" + "fastify-cors": "~4.1.0", + "fastify-gql": "~5.6.0", + "fastify-helmet": "~5.0.1", + "fastify-no-icon": "~4.0.0", + "fastify-plugin": "~2.3.3", + "graphql-tools": "~6.1.0" }, "devDependencies": { "@commitlint/cli": "~8.3.5", @@ -51,10 +48,12 @@ "@types/mkdirp": "~1.0.0", "@types/node": "~14.6.0", "@types/qs": "6.9.1", - "@typescript-eslint/eslint-plugin": "~2.34.0", - "@typescript-eslint/parser": "~2.34.0", "@types/require-from-string": "~1.2.0", "@types/sade": "~1.7.0", + "@types/tap": "~14.10.0", + "@types/ws": "~7.2.6", + "@typescript-eslint/eslint-plugin": "~2.34.0", + "@typescript-eslint/parser": "~2.34.0", "chalk": "~4.1.0", "commitizen": "~4.2.1", "commitlint-config-cz": "~0.13.0", @@ -76,7 +75,7 @@ "rimraf": "~3.0.0", "sade": "~1.7.3", "source-map-support": "~0.5.16", - "tap": "~14.10.5", + "tap": "~14.10.8", "tap-mocha-reporter": "~5.0.0", "typescript": "~3.9.2" }, diff --git a/src/app.ts b/src/app.ts index 8a62d226..4b76ac52 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,40 +1,26 @@ +import { Server, IncomingMessage, ServerResponse } from 'http' +import { FastifyInstance, FastifyPluginOptions } from 'fastify' +import fastifyCors from 'fastify-cors' +import fastifyHelmet from 'fastify-helmet' +import fastifyAutoload from 'fastify-autoload' import { join } from 'path' -import AutoLoad from 'fastify-autoload' -import { FastifyInstance } from 'fastify' -import { nextCallback } from 'fastify-plugin' -import noIcon from 'fastify-no-icon' -import helmet from 'fastify-helmet' -import qs from 'qs' -import cors from 'fastify-cors' +import GQL from 'fastify-gql' +import schema from './graphql/schema' +import resolvers from './graphql/resolvers' -function HospitalRun(fastify: FastifyInstance, opts: any, next: nextCallback) { - fastify.register(cors, { +export default ( + fastify: FastifyInstance, + _: FastifyPluginOptions, + next: (error?: Error) => void, +) => { + fastify.register(fastifyCors, { allowedHeaders: ['Content-Type', 'Authorization'], }) - fastify.register(helmet) - fastify.register(noIcon) - - // This loads all application wide plugins defined in plugins folder - fastify.register(AutoLoad, { - dir: join(__dirname, 'plugins'), - includeTypeScript: true, - options: { ...opts }, - }) - - // This loads all routes and services defined in services folder - fastify.register(AutoLoad, { + fastify.register(fastifyHelmet) + fastify.register(fastifyAutoload, { dir: join(__dirname, 'services'), - includeTypeScript: true, - options: { ...opts }, }) + fastify.register(GQL, { schema, resolvers }) next() } - -HospitalRun.options = { - querystringParser: (str: string) => qs.parse(str), - logger: true, - ignoreTrailingSlash: true, -} - -export = HospitalRun diff --git a/src/graphql/resolvers.ts b/src/graphql/resolvers.ts new file mode 100644 index 00000000..d47818d0 --- /dev/null +++ b/src/graphql/resolvers.ts @@ -0,0 +1,7 @@ +const resolvers = { + Query: { + add: async (_: any, { x, y }: any) => x + y, + }, +} + +export default resolvers diff --git a/src/graphql/schema.ts b/src/graphql/schema.ts new file mode 100644 index 00000000..c13a2253 --- /dev/null +++ b/src/graphql/schema.ts @@ -0,0 +1,7 @@ +const schema = ` + type Query { + add(x: Int, y: Int): Int + } +` + +export default schema diff --git a/src/index.ts b/src/index.ts index 8ddd38ac..aa5ce1c5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,26 +1,19 @@ -// we need this file because of this issue: https://github.com/fastify/fastify-cli/issues/131 -import 'make-promises-safe' import Fastify from 'fastify' -import hospitalRun from './app' +import app from './app' const port = Number(process.env.PORT) || 3000 -const ip = process.env.IP || '0.0.0.0' +const ip = process.env.IP || 'localhost' -const fastify = Fastify(hospitalRun.options) -fastify.register(hospitalRun) +const fastify = Fastify({ + ignoreTrailingSlash: true, + logger: true, +}) -if (process.env.NODE_ENV !== 'production') { - // eslint-disable-next-line - const blipp = require('fastify-blipp') - fastify.register(blipp) -} +fastify.register(app) fastify.listen(port, ip, err => { if (err) { - fastify.log.error(err) + console.log(err) process.exit(1) } - if (process.env.NODE_ENV !== 'production') { - fastify.blipp() - } }) diff --git a/src/plugins/support.ts b/src/plugins/support.ts deleted file mode 100644 index 50d9da3c..00000000 --- a/src/plugins/support.ts +++ /dev/null @@ -1,14 +0,0 @@ -import fp from 'fastify-plugin' - -export default fp((fastify, _, next) => { - fastify.decorate('someSupport', function () { - return 'hugs' - }) - next() -}) - -declare module 'fastify' { - interface FastifyInstance { - someSupport(): string - } -} diff --git a/src/services/health.ts b/src/services/health.ts new file mode 100644 index 00000000..12136e37 --- /dev/null +++ b/src/services/health.ts @@ -0,0 +1,13 @@ +import { Server, IncomingMessage, ServerResponse } from 'http' +import { FastifyInstance, FastifyPluginOptions } from 'fastify' + +export default ( + fastify: FastifyInstance, + _: FastifyPluginOptions, + next: (error?: Error) => void, +) => { + fastify.get('/health', (_, reply) => { + reply.send({ status: 'UP' }) + }) + next() +} diff --git a/src/services/root.ts b/src/services/root.ts index 07376de1..3bf3fe0e 100644 --- a/src/services/root.ts +++ b/src/services/root.ts @@ -1,14 +1,15 @@ import { Server, IncomingMessage, ServerResponse } from 'http' -import { FastifyInstance } from 'fastify' -import { nextCallback } from 'fastify-plugin' +import { FastifyInstance, FastifyPluginOptions } from 'fastify' export default ( fastify: FastifyInstance, - _: {}, - next: nextCallback, + _: FastifyPluginOptions, + next: (error?: Error) => void, ) => { fastify.get('/', (_, reply) => { - reply.send({ root: true }) + const query = '{ add(x: 2, y: 2) }' + return reply.graphql(query) }) + next() } diff --git a/test/helper.ts b/test/helper.ts index 47cf2994..7a2bc624 100644 --- a/test/helper.ts +++ b/test/helper.ts @@ -1,6 +1,6 @@ import Fastify from 'fastify' import fp from 'fastify-plugin' -import App from '../src/app' +import App from './../src/app' // Fill in this config with all the configurations // needed for testing the application diff --git a/test/plugins/support.test.ts b/test/plugins/support.test.ts deleted file mode 100644 index a0d3bad6..00000000 --- a/test/plugins/support.test.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { test } from 'tap' -import Fastify from 'fastify' -import Support from '../../src/plugins/support' - -test('support works standalone', async (t: any) => { - const fastify = Fastify() - fastify.register(Support) - - await fastify.ready() - t.equal(fastify.someSupport(), 'hugs') -}) diff --git a/test/services/root.test.ts b/test/services/health.test.ts similarity index 52% rename from test/services/root.test.ts rename to test/services/health.test.ts index 0119b9b6..8e359371 100644 --- a/test/services/root.test.ts +++ b/test/services/health.test.ts @@ -1,11 +1,11 @@ import { test } from 'tap' import { build } from '../helper' -test('default root route', async (t: any) => { +test('default root route', async t => { const app = build(t) const res = await app.inject({ - url: '/', + url: '/health', }) - t.deepEqual(JSON.parse(res.payload), { root: true }) + t.deepEqual(JSON.parse(res.payload), { status: 'UP' }) }) diff --git a/typings/fastify-blipp/index.d.ts b/typings/fastify-blipp/index.d.ts deleted file mode 100644 index 32a7a590..00000000 --- a/typings/fastify-blipp/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare module 'fastify-blipp' { - import { Plugin } from 'fastify' - import http from 'http' - - let blipp: Plugin - export default blipp -} diff --git a/typings/fastify-no-icon/index.d.ts b/typings/fastify-no-icon/index.d.ts deleted file mode 100644 index feb0499b..00000000 --- a/typings/fastify-no-icon/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare module 'fastify-no-icon' { - import { Plugin } from 'fastify' - import http from 'http' - - let noIcon: Plugin - export default noIcon -} diff --git a/typings/fastify/index.d.ts b/typings/fastify/index.d.ts deleted file mode 100644 index f27d87af..00000000 --- a/typings/fastify/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import 'fastify' -declare module 'fastify' { - interface FastifyInstance { - blipp(): unknown - } -} diff --git a/typings/tap/index.d.ts b/typings/tap/index.d.ts deleted file mode 100644 index b70a31f2..00000000 --- a/typings/tap/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -// improve tap typings and publish them on @types/tap - -declare module 'tap' { - function test(description: string, t: unknown): unknown -} From c0a1cbd7e269601f0712df2656143a43a41125ee Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Mon, 31 Aug 2020 00:20:29 -0500 Subject: [PATCH 31/35] style: require arrow function parentheses --- .prettierrc | 2 +- src/index.ts | 2 +- test/services/health.test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.prettierrc b/.prettierrc index 48360d60..87b4a12b 100644 --- a/.prettierrc +++ b/.prettierrc @@ -6,7 +6,7 @@ "trailingComma": "all", "bracketSpacing": true, "jsxBracketSameLine": false, - "arrowParens": "avoid", + "arrowParens": "always", "endOfLine": "lf", "parser": "typescript" } diff --git a/src/index.ts b/src/index.ts index aa5ce1c5..88894362 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,7 +11,7 @@ const fastify = Fastify({ fastify.register(app) -fastify.listen(port, ip, err => { +fastify.listen(port, ip, (err) => { if (err) { console.log(err) process.exit(1) diff --git a/test/services/health.test.ts b/test/services/health.test.ts index 8e359371..30dbf82b 100644 --- a/test/services/health.test.ts +++ b/test/services/health.test.ts @@ -1,7 +1,7 @@ import { test } from 'tap' import { build } from '../helper' -test('default root route', async t => { +test('default root route', async (t) => { const app = build(t) const res = await app.inject({ From 16256c6310e6534402b3113310863c70006dcd06 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 31 Aug 2020 22:39:55 +0000 Subject: [PATCH 32/35] build(deps-dev): bump prettier from 2.0.5 to 2.1.1 Bumps [prettier](https://github.com/prettier/prettier) from 2.0.5 to 2.1.1. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/2.0.5...2.1.1) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6475c49c..7377a6c0 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "npm-run-all": "~4.1.5", "pino-colada": "~2.1.0", "pouchdb-server": "~4.2.0", - "prettier": "~2.0.2", + "prettier": "~2.1.1", "rimraf": "~3.0.0", "sade": "~1.7.3", "source-map-support": "~0.5.16", From 237c1a99a125fcde565f8e31c5d6186308e9257b Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Mon, 31 Aug 2020 20:17:11 -0500 Subject: [PATCH 33/35] feat: add docker compose --- docker-compose.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..76b956bc --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3' + +services: + mongo: + image: mongo + restart: always + environment: + MONGO_INITDB_DATABASE: hospitalrun + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: password From a89c1d101659f6bd4ac68ef4b1da80e8598769cf Mon Sep 17 00:00:00 2001 From: Jack Meyer Date: Tue, 1 Sep 2020 00:08:37 -0500 Subject: [PATCH 34/35] style: use fastify logging --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 88894362..0d41d15d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,7 +13,7 @@ fastify.register(app) fastify.listen(port, ip, (err) => { if (err) { - console.log(err) + fastify.log.error(err) process.exit(1) } }) From 8cc55397a1fff6b341ada3f8a99aa7846116fccc Mon Sep 17 00:00:00 2001 From: Matteo Vivona Date: Tue, 1 Sep 2020 20:42:49 +0200 Subject: [PATCH 35/35] chore(release): 2.0.0-alpha.3 --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41a1c654..be9d650f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [2.0.0-alpha.3](https://github.com/HospitalRun/hospitalrun-server/compare/v2.0.0-alpha.2...v2.0.0-alpha.3) (2020-09-01) + + +### Features + +* add docker compose ([237c1a9](https://github.com/HospitalRun/hospitalrun-server/commit/237c1a99a125fcde565f8e31c5d6186308e9257b)) + ## 2.0.0-alpha.2 (2020-05-17) diff --git a/package.json b/package.json index 1d0f546d..94fbfc11 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hospitalrun/server", - "version": "2.0.0-alpha.2", + "version": "2.0.0-alpha.3", "description": "HospitalRun Node.js server", "main": "dist", "repository": {